From 5d7ba2518694f6694794bebb7389f9a85374720b Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期二, 20 五月 2025 19:02:17 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/SCGL/日计划管理/JIT_DayPlanPlatFormBillController.cs | 1098 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 1,032 insertions(+), 66 deletions(-)

diff --git "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormBillController.cs" "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormBillController.cs"
index 325f71c..f7543e4 100644
--- "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormBillController.cs"
+++ "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormBillController.cs"
@@ -9,7 +9,7 @@
 using Newtonsoft.Json.Linq;
 using System.Diagnostics;
 using System.Threading;
-
+using System.Globalization;
 namespace WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�
 {
     public class JIT_DayPlanPlatFormBillController : ApiController
@@ -98,6 +98,40 @@
                 return objJsonResult;
             }
         }
+
+        /// <summary>
+        /// 鏍规嵁鐐瑰嚮琛屾爣棰樻椂闂存煡璇㈢己鏂欏垎鏋�
+        /// </summary>
+        /// <param name="sWhere"></param>
+        /// <param name="user"></param>
+        /// <returns></returns>
+        [Route("JIT_DayPlanPlatFormBill/JIT_DayPlanPlatFormBillHDateTimeList")]
+        [HttpGet]
+        public object JIT_DayPlanPlatFormBillHDateTimeList(string sWhere)
+        {
+            try
+            {
+                MaterialShorAnalysis Report = JsonConvert.DeserializeObject<MaterialShorAnalysis>(sWhere);
+
+                ds = oCN.RunProcReturn($"exec h_p_JIT_MaterialShorAnalysisReportList {Report.HORGID},'{Report.HBEGINDATE}','{Report.HENDDATE}' ", "h_p_JIT_PODemandPlanBill_ReportList");
+
+               
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                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 鐢熶骇鏃ヨ鍒掑钩鍙� 淇濆瓨
@@ -135,6 +169,9 @@
 
             try
             {
+                Stopwatch sw = new Stopwatch();//璁℃椂鍣�
+                sw.Start();//寮�濮嬭鏃�
+
                 if (!DBUtility.ClsPub.Security_Log("Sc_WorkBillSortBill_Edit", 1, false, user))
                 {
                     objJsonResult.code = "0";
@@ -160,15 +197,19 @@
 
                 LogService.CustomWriteLog("2:", DateTime.Now.ToString("yyyy-MM-dd"));
                 int TrueCount = 0, SumCount = 0;
+                LogService.CustomWriteLog("list.Count:"+ list.Count, DateTime.Now.ToString("yyyy-MM-dd"));
 
+                string sReturn = "";
+                oSystemParameter.ShowBill(ref sReturn);
                 for (int i = 0; i < list.Count; i++)
-                {
+                {                                     
                     TrueCount = 0;
                     SumCount = 0;
                     long HInterID = 0;
                     var HBillNo = "";
                     if (list[i]["鍗曟嵁鍙�"].ToString() == "" && list[i]["hmainid"].ToString() == "")
                     {
+                        LogService.CustomWriteLog("2.01:" + i, DateTime.Now.ToString("yyyy-MM-dd"));
                         var HICMOBillNo = list[i]["鐢熶骇璁㈠崟鍙�"].ToString();
                         var HOrderType = list[i]["璁㈠崟绫诲瀷"].ToString();
                         var HICMOEntrySEQ = list[i]["鐢熶骇璁㈠崟鏄庣粏琛屽彿"].ToString();
@@ -178,7 +219,7 @@
                         var HProdORGID = list[i]["HProdORGID"].ToString();
                         var HMaterID = list[i]["HMaterID"].ToString();
                         var HMaterName = list[i]["鐗╂枡鍚嶇О"].ToString();
-                        var HMaterModel = list[i]["瑙勬牸鍨嬪彿"].ToString();
+                        var HMaterModel = list[i]["瑙勬牸鍨嬪彿"].ToString().Replace("'", "''");
                         var HUnitID = list[i]["HUnitID"].ToString();
                         var HSeOrderBillQty = list[i]["閿�鍞鍗曟暟閲�"].ToString();
                         //var HOrderNeedQty = list[i]["璁㈠崟闇�姹傛暟閲�"].ToString();
@@ -194,18 +235,27 @@
                         var HMainSourceInterID = list[i]["婧愬崟涓诲唴鐮�"].ToString();
                         var HMainSourceEntryID = list[i]["婧愬崟瀛愬唴鐮�"].ToString();
                         var HPlanQty = list[i]["璁″垝鏁伴噺"].ToString();
+                        var HEmpID = list[i]["HEmpID"].ToString();
+                        var HWorkQty = list[i]["灏忔椂浜ц兘"].ToString();
+                        var HSourceName = list[i]["鐢熶骇璧勬簮"].ToString();
+                        var HWorkQty_ProdLine = list[i]["浜х嚎鎬讳骇鑳�"].ToString();
 
-                        if (HSourceID == ""|| HSourceID == "0")
+                        LogService.CustomWriteLog("2.05:" + i, DateTime.Now.ToString("yyyy-MM-dd"));
+
+                        if (oSystemParameter.omodel.WMS_CampanyName != "娣诲悍绉戞妧"&& oSystemParameter.omodel.WMS_CampanyName != "涓夊崌") //绯荤粺鍙傛暟  瀹㈡埛瀹氬埗鍖栧悕绉�     绌虹櫧涓洪�氱敤
                         {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = $"绗瑊i + 1}琛岀敓浜ц祫婧愪笉鑳戒负绌�!";
-                            objJsonResult.data = null;
-                            return objJsonResult;
+                            if (HSourceID == "" || HSourceID == "0")
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = $"绗瑊i + 1}琛岀敓浜ц祫婧愪笉鑳戒负绌�!";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
                         }
+                        ds = oCN.RunProcReturn($"select HInterID,HICMOBillNo from Sc_WorkBillSortBillMain with(nolock) where HMainSourceInterID={HMainSourceInterID}" +
+                            $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID} and ISNULL(HDeleteMan,'')=''", "Sc_WorkBillSortBillMain");
 
-                        ds = oCN.RunProcReturn($"select * from Sc_WorkBillSortBillMain a inner join Sc_WorkBillSortBillSub b on a.HInterID = b.HInterID where HMainSourceInterID={HMainSourceInterID}" +
-                            $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID}", "Sc_WorkBillSortBillMain");
                         if (ds.Tables[0].Rows.Count > 0)
                         {
                             objJsonResult.code = "0";
@@ -226,7 +276,7 @@
                             " HOrderNeedQty, HSplitQty, HDayPlanSumQty,HPlanBeginDate," +
                             "HSeOrderBillNo,HICMOBillType,HSourceStockInQty,HLeftPlanQty,HOrderLev,HPreparatDate," +
                             "HMainSourceInterID,HMainSourceEntryID,HICMOInterID_Sec,HICMOEntryID_Sec,HPlanQty" +
-                            ",HICMOInterID,HICMOEntryID,HPlanEndDate)values" +
+                            ",HICMOInterID,HICMOEntryID,HPlanEndDate,HEmpID,HWorkQty,HSourceName,HWorkQty_ProdLine)values" +
                             $"({HInterID},'{HBillNo}',{DateTime.Now.Year},{DateTime.Now.Month},'{BillType}'," +
                             $"'{BillType}',GETDATE(),1,'{user}',getdate(),'{HICMOBillNo}','{HOrderType}'," +
                             $"{(HICMOEntrySEQ == "" ? 0.ToString() : HICMOEntrySEQ)},{(HWorkShopID == "" ? 0.ToString() : HWorkShopID)},{(HSourceID == "" ? 0.ToString() : HSourceID)}, {(HYX == "" ? 0.ToString() : HYX)}, {(HProdORGID == "" ? 0.ToString() : HProdORGID)}," +
@@ -234,7 +284,7 @@
                             $" 0, {(HSplitQty == "" ? 0.ToString() : HSplitQty)}, {(HDayPlanSumQty == "" ? 0.ToString() : HDayPlanSumQty)},'{HPlanBeginDate}'," +
                             $"'{HSeOrderBillNo}','{HICMOBillType}',{(HSourceStockInQty == "" ? 0.ToString() : HSourceStockInQty)},{(HLeftPlanQty == "" ? 0.ToString() : HLeftPlanQty)},'{HOrderLev}',getdate()," +
                             $"{HMainSourceInterID},{HMainSourceEntryID},{HMainSourceInterID},{HMainSourceEntryID},{HPlanQty}," +
-                            $"{HMainSourceInterID},{HMainSourceEntryID},'{HPlanEndDate}')";
+                            $"{HMainSourceInterID},{HMainSourceEntryID},'{HPlanEndDate}','{HEmpID}','{HWorkQty}','{HSourceName}','{HWorkQty_ProdLine}')";
 
                         //LogService.Write("sql:" + sql);
                         //涓昏〃
@@ -242,6 +292,7 @@
                     }
                     else
                     {
+                        LogService.CustomWriteLog("2.0:" + i, DateTime.Now.ToString("yyyy-MM-dd"));
                         HBillNo = list[i]["鍗曟嵁鍙�"].ToString();
                         HInterID = int.Parse(list[i]["hmainid"].ToString());
                         var HMainSourceInterID = list[i]["婧愬崟涓诲唴鐮�"].ToString();
@@ -259,15 +310,41 @@
                         var HOrderCommitDate = list[i]["璁㈠崟浜よ揣鏈�"].ToString();
                         var HPlanEndDate = list[i]["璁″垝缁撴潫鏃ユ湡"].ToString();
                         var HSplitQty = list[i]["鎷嗗崟鏁伴噺"].ToString();
+                        var HSourceName = list[i]["鐢熶骇璧勬簮"].ToString();
+                        var HWorkQty_ProdLine = list[i]["浜х嚎鎬讳骇鑳�"].ToString();
 
-                        if (HSourceID == "" || HSourceID == "0")
+                        var HOrderType = list[i]["璁㈠崟绫诲瀷"].ToString();
+                        var HWorkShopID = list[i]["HWorkShopID"].ToString();
+                        var HProdORGID = list[i]["HProdORGID"].ToString();
+                        var HMaterID = list[i]["HMaterID"].ToString();
+                        var HMaterName = list[i]["鐗╂枡鍚嶇О"].ToString();
+                        var HMaterModel = list[i]["瑙勬牸鍨嬪彿"].ToString().Replace("'", "''");
+                        var HUnitID = list[i]["HUnitID"].ToString();
+                        var HSeOrderBillQty = list[i]["閿�鍞鍗曟暟閲�"].ToString();
+                        var HDayPlanSumQty = list[i]["鏃ヨ鍒掓暟閲忔�婚噺"].ToString();
+                        var HPlanBeginDate = list[i]["璁″垝寮�濮嬫棩鏈�"].ToString();
+                        var HSeOrderBillNo = list[i]["閿�鍞鍗曞彿"].ToString();
+                        var HICMOBillType = list[i]["鐢熶骇璁㈠崟鍗曟嵁绫诲瀷"].ToString();
+                        var HSourceStockInQty = list[i]["浜х嚎鍏ュ簱鏁伴噺"].ToString();
+                        var HLeftPlanQty = list[i]["鏈帓鏁伴噺"].ToString();
+                        var HOrderLev = list[i]["璁㈠崟绛夌骇"].ToString();
+                        var HPlanQty = list[i]["璁″垝鏁伴噺"].ToString();
+                        var HEmpID = list[i]["HEmpID"].ToString();
+
+                        LogService.CustomWriteLog("2.1:"+i, DateTime.Now.ToString("yyyy-MM-dd"));
+                        
+                        if (oSystemParameter.omodel.WMS_CampanyName != "娣诲悍绉戞妧" && oSystemParameter.omodel.WMS_CampanyName != "涓夊崌") //绯荤粺鍙傛暟  瀹㈡埛瀹氬埗鍖栧悕绉�     绌虹櫧涓洪�氱敤
                         {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = $"绗瑊i + 1}琛岀敓浜ц祫婧愪笉鑳戒负绌�!";
-                            objJsonResult.data = null;
-                            return objJsonResult;
+                            if (HSourceID == "" || HSourceID == "0")
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = $"绗瑊i + 1}琛岀敓浜ц祫婧愪笉鑳戒负绌�!";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
                         }
+
                         var str = 0;
                         if (!int.TryParse(HYX, out str))
                         {
@@ -278,32 +355,170 @@
                             return objJsonResult;
                         }
 
-                        ds = oCN.RunProcReturn($"select * from  Sc_WorkBillSortBillMain where HMainSourceInterID={HMainSourceInterID}" +
-                              $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID}", "Sc_WorkBillSortBillMain");
-
-                        if (ds.Tables[0].Rows.Count > 1)
+                        if (oSystemParameter.omodel.WMS_CampanyName == "娣诲悍绉戞妧") //绯荤粺鍙傛暟  瀹㈡埛瀹氬埗鍖栧悕绉�     绌虹櫧涓洪�氱敤
                         {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = $"绗瑊i + 1}琛岀敓浜ц祫婧愭湁閲嶅,璇蜂慨鏀�!";
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
+                            //鐪嬫湁鍑犲彴鐢熶骇璧勬簮鍗忓悓鐢熶骇
+                            string[] HSourceNameArr = HSourceName.Split(new char[]{'&'});
 
-                        oCN.RunProc($"update Sc_WorkBillSortBillMain set HSourceID={(HSourceID == "" ? 0.ToString() : HSourceID)},HYX={HYX}" +
-                            $",HWorkQty={HWorkQty},HProdTimes={HProdTimes},HReadyTimes={HReadyTimes},HLastBeginDate='{HLastBeginDate}'" +
-                            $",HLastEndDate='{HLastEndDate}',HOrderNeedQty={HOrderNeedQty},HOrderCommitDate='{HOrderCommitDate}',HPlanEndDate='{HPlanEndDate}',HSplitQty={HSplitQty}" +
-                            $" where HInterID={list[i]["hmainid"].ToString()} and HBillNo='{list[i]["鍗曟嵁鍙�"].ToString()}'");
+                            if (HSourceNameArr.Length >= 2)
+                            {
+                                for (int s = 0; s < HSourceNameArr.Length; s++)
+                                {
+                                    if (s == 0)
+                                    {
+                                        ds = oCN.RunProcReturn("select HItemID from Gy_Source with(nolock) where HName = '" + HSourceNameArr[s] + "'", "Gy_Source");
+
+                                        var HSourceID_Child = ds.Tables[0].Rows[0]["HItemID"];
+
+                                        oCN.RunProc($"update Sc_WorkBillSortBillMain set HSourceID={(HSourceID_Child == "" ? 0.ToString() : HSourceID_Child)}" +
+                                            $",HYX={HYX},HWorkQty={HWorkQty},HProdTimes={HProdTimes},HReadyTimes={HReadyTimes},HLastBeginDate='{HLastBeginDate}'" +
+                                            $",HLastEndDate='{HLastEndDate}',HOrderNeedQty={HOrderNeedQty},HOrderCommitDate='{HOrderCommitDate}'" +
+                                            $",HPlanEndDate='{HPlanEndDate}',HSplitQty={HSplitQty},HSourceName='{HSourceName}',HWorkQty_ProdLine={HWorkQty_ProdLine}" +
+                                            $" where HInterID={list[i]["hmainid"].ToString()} and HBillNo='{list[i]["鍗曟嵁鍙�"].ToString()}'");
+                                    }
+                                    else
+                                    {
+                                        ds = oCN.RunProcReturn("select HItemID from Gy_Source with(nolock) where HName = '" + HSourceNameArr[s] + "'", "Gy_Source");
+
+                                        var HSourceID_Child = ds.Tables[0].Rows[0]["HItemID"];
+
+                                        //鏂板鍗忓悓鐢熶骇璧勬簮鐨勬帓浜ц褰�
+                                        ds = oCN.RunProcReturn($"select HInterID,HICMOBillNo from Sc_WorkBillSortBillMain with(nolock) where HMainSourceInterID={HMainSourceInterID}" +
+                           $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID_Child}", "Sc_WorkBillSortBillMain");
+
+                                        if (ds.Tables[0].Rows.Count > 0)
+                                        {
+                                            objJsonResult.code = "0";
+                                            objJsonResult.count = 0;
+                                            objJsonResult.Message = $"绗瑊i + 1}琛岀敓浜ц祫婧愭湁閲嶅,璇蜂慨鏀�!";
+                                            objJsonResult.data = null;
+                                            return objJsonResult;
+                                        }
+
+                                        //鏂板鍗曟嵁鍙� id
+                                        var HBillNo_New = DBUtility.ClsPub.CreateBillCode_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);//鑾峰緱涓�涓柊鐨勫崟鎹彿
+                                        var HInterID_New = DBUtility.ClsPub.CreateBillID_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo);//鑾峰緱涓�涓柊鐨刬d
+
+                                        string sql = $"insert into Sc_WorkBillSortBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType," +
+                                            "HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HICMOBillNo,HOrderType," +
+                                            "HICMOEntrySEQ,HWorkShopID,HSourceID, HYX, HProdORGID," +
+                                            " HMaterID, HMaterName, HMaterModel, HUnitID, HSeOrderBillQty," +
+                                            " HOrderNeedQty, HSplitQty, HDayPlanSumQty,HPlanBeginDate," +
+                                            "HSeOrderBillNo,HICMOBillType,HSourceStockInQty,HLeftPlanQty,HOrderLev,HPreparatDate," +
+                                            "HMainSourceInterID,HMainSourceEntryID,HICMOInterID_Sec,HICMOEntryID_Sec,HPlanQty" +
+                                            ",HICMOInterID,HICMOEntryID,HPlanEndDate,HEmpID,HWorkQty,HSourceName,HWorkQty_ProdLine,HRemark)values" +
+                                            $"({HInterID_New},'{HBillNo_New}',{DateTime.Now.Year},{DateTime.Now.Month},'{BillType}'," +
+                                            $"'{BillType}',GETDATE(),1,'{user}',getdate(),'{HICMOBillNo}','{HOrderType}'," +
+                                            $"{(HICMOEntrySEQ == "" ? 0.ToString() : HICMOEntrySEQ)},{(HWorkShopID == "" ? 0.ToString() : HWorkShopID)},{(HSourceID_Child == "" ? 0.ToString() : HSourceID_Child)}, {(HYX == "" ? 0.ToString() : HYX)}, {(HProdORGID == "" ? 0.ToString() : HProdORGID)}," +
+                                            $" {(HMaterID == "" ? 0.ToString() : HMaterID)}, '{HMaterName}', '{HMaterModel}', {(HUnitID == "" ? 0.ToString() : HUnitID)}, {(HSeOrderBillQty == "" ? 0.ToString() : HSeOrderBillQty)}," +
+                                            $" 0, {(HSplitQty == "" ? 0.ToString() : HSplitQty)}, {(HDayPlanSumQty == "" ? 0.ToString() : HDayPlanSumQty)},'{HPlanBeginDate}'," +
+                                            $"'{HSeOrderBillNo}','{HICMOBillType}',{(HSourceStockInQty == "" ? 0.ToString() : HSourceStockInQty)},{(HLeftPlanQty == "" ? 0.ToString() : HLeftPlanQty)},'{HOrderLev}',getdate()," +
+                                            $"{HMainSourceInterID},{HMainSourceEntryID},{HMainSourceInterID},{HMainSourceEntryID},{HPlanQty}," +
+                                            $"{HMainSourceInterID},{HMainSourceEntryID},'{HPlanEndDate}','{HEmpID}','{HWorkQty}','{HSourceName}','{HWorkQty_ProdLine}','{"鍗忓悓鐢熶骇"}')";
+
+                                        //LogService.Write("sql:" + sql);
+                                        //涓昏〃
+                                        oCN.RunProc(sql);
+
+                                        //鎻掑叆瀛愯〃鏁版嵁
+                                        for (int j = 0; j < 180; j++)
+                                        {                                           
+                                            //涓昏〃鏈夋暟鎹� 瀛愯〃鏃犳暟鎹�
+                                            //if (j == 180 - 1 && SumCount == 0 && HInterID_New != 0 && HBillNo_New != "")
+                                            //{
+                                            //    objJsonResult = AddBillSub(HInterID_New.ToString(), HBillNo_New, DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd").ToString()), 0, list[i]);
+                                            //}
+
+
+                                            if (list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString() != "")
+                                            {
+                                                ////淇濆瓨瀛愯〃
+                                                objJsonResult = AddBillSub(HInterID_New == 0 ? list[i]["hmainid"].ToString() : HInterID_New.ToString()
+                                                    , HBillNo_New == "" ? list[i]["鍗曟嵁鍙�"].ToString() : HBillNo_New
+                                                     , DateTime.Parse(DateTime.Now.AddDays(j).ToString("yyyy-MM-dd").ToString())
+                                                     , 0
+                                                     , list[i]);
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                            else
+                            {
+                                ds = oCN.RunProcReturn($"select HInterID,HICMOBillNo from Sc_WorkBillSortBillMain with(nolock) where HMainSourceInterID={HMainSourceInterID}" +
+                             $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID}", "Sc_WorkBillSortBillMain");
+
+                                if (ds.Tables[0].Rows.Count > 1)
+                                {
+                                    LogService.CustomWriteLog("绗�" + i + 1 + "琛岀敓浜ц祫婧愭湁閲嶅,璇蜂慨鏀�", DateTime.Now.ToString("yyyy-MM-dd"));
+                                    LogService.CustomWriteLog($"select * from  Sc_WorkBillSortBillMain where HMainSourceInterID={HMainSourceInterID}" +
+                                      $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID}", DateTime.Now.ToString("yyyy-MM-dd"));
+                                    objJsonResult.code = "0";
+                                    objJsonResult.count = 0;
+                                    objJsonResult.Message = $"绗瑊i + 1}琛岀敓浜ц祫婧愭湁閲嶅,璇蜂慨鏀�!";
+                                    objJsonResult.data = null;
+                                    return objJsonResult;
+                                }
+                                LogService.CustomWriteLog("2.2:" + i, DateTime.Now.ToString("yyyy-MM-dd"));
+
+                                oCN.RunProc($"update Sc_WorkBillSortBillMain set HSourceID={(HSourceID == "" ? 0.ToString() : HSourceID)},HYX={HYX}" +
+                                    $",HWorkQty={HWorkQty},HProdTimes={HProdTimes},HReadyTimes={HReadyTimes},HLastBeginDate='{HLastBeginDate}'" +
+                                    $",HLastEndDate='{HLastEndDate}',HOrderNeedQty={HOrderNeedQty},HOrderCommitDate='{HOrderCommitDate}',HPlanEndDate='{HPlanEndDate}',HSplitQty={HSplitQty},HSourceName='{HSourceName}',HWorkQty_ProdLine={HWorkQty_ProdLine}" +
+                                    $" where HInterID={list[i]["hmainid"].ToString()} and HBillNo='{list[i]["鍗曟嵁鍙�"].ToString()}'");
+                            }
+                        }
+                        else
+                        {
+                            ds = oCN.RunProcReturn($"select HInterID,HICMOBillNo from Sc_WorkBillSortBillMain with(nolock) where HMainSourceInterID={HMainSourceInterID}" +
+                             $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID} and ISNULL(HDeleteMan,'') = ''", "Sc_WorkBillSortBillMain");
+
+                            if (ds.Tables[0].Rows.Count > 1)
+                            {
+                                LogService.CustomWriteLog("绗�" + i + 1 + "琛岀敓浜ц祫婧愭湁閲嶅,璇蜂慨鏀�", DateTime.Now.ToString("yyyy-MM-dd"));
+                                LogService.CustomWriteLog($"select * from  Sc_WorkBillSortBillMain where HMainSourceInterID={HMainSourceInterID}" +
+                                  $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID} and ISNULL(HDeleteMan,'')=''", DateTime.Now.ToString("yyyy-MM-dd"));
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = $"绗瑊i + 1}琛岀敓浜ц祫婧愭湁閲嶅,璇蜂慨鏀�!";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                            LogService.CustomWriteLog("2.2:" + i, DateTime.Now.ToString("yyyy-MM-dd"));
+
+                            oCN.RunProc($"update Sc_WorkBillSortBillMain set HSourceID={(HSourceID == "" ? 0.ToString() : HSourceID)},HYX={HYX}" +
+                                $",HWorkQty={HWorkQty},HProdTimes={HProdTimes},HReadyTimes={HReadyTimes},HLastBeginDate='{HLastBeginDate}'" +
+                                $",HLastEndDate='{HLastEndDate}',HOrderNeedQty={HOrderNeedQty},HOrderCommitDate='{HOrderCommitDate}',HPlanEndDate='{HPlanEndDate}',HSplitQty={HSplitQty},HSourceName='{HSourceName}',HWorkQty_ProdLine={HWorkQty_ProdLine}" +
+                                $" where HInterID={list[i]["hmainid"].ToString()} and HBillNo='{list[i]["鍗曟嵁鍙�"].ToString()}'");
+                        }                       
                     }
 
                     oCN.RunProc($"update Sc_WorkBillSortBillMain set HDayPlanSumQty={list[i]["鏃ヨ鍒掓暟閲忔�婚噺"].ToString()} where HInterID={(HInterID==0?int.Parse(list[i]["hmainid"].ToString()):HInterID)} and HBillNo='{(HBillNo==""?list[i]["鍗曟嵁鍙�"].ToString(): HBillNo)}'");
 
-                    int SumDay = 31; //鍔ㄦ�佷袱鏈堜箣宸� DateTime.Now.AddMonths(1).AddDays(-1).Subtract(DateTime.Now).Days;
+                    int SumDay = 0; //鍔ㄦ�佷袱鏈堜箣宸� DateTime.Now.AddMonths(1).AddDays(-1).Subtract(DateTime.Now).Days;
 
+                    // 缁熻鎬诲ぉ鏁�
+                    HashSet<DateTime> uniqueDates = new HashSet<DateTime>();
+
+                    foreach (var key in list[i].Keys)
+                    {
+                        if (DateTime.TryParseExact(key, "yyyy-M-d", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime date))
+                        {
+                            uniqueDates.Add(date);
+                        }
+                    }
+
+                    SumDay = uniqueDates.Count;
+
+                    if (oSystemParameter.omodel.WMS_CampanyName == "娣诲悍绉戞妧") //绯荤粺鍙傛暟  瀹㈡埛瀹氬埗鍖栧悕绉�     绌虹櫧涓洪�氱敤
+                    {
+                        SumDay = 180;
+                    }            
+
+                    LogService.CustomWriteLog("2.3:" + i, DateTime.Now.ToString("yyyy-MM-dd"));
                     for (int j = 0; j < SumDay; j++)
                     {
                         //涓昏〃瀛愯〃閮芥湁鏁版嵁
-                        if (list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString() != "")
+                        if (list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString() != ""&& Math.Round(double.Parse(list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString()),1)>0)
                         {
                             SumCount += 1;
                             ////淇濆瓨瀛愯〃
@@ -318,12 +533,14 @@
                             }
                         }
                         //涓昏〃鏈夋暟鎹� 瀛愯〃鏃犳暟鎹�
-                        if (j == 30 && SumCount == 0 && HInterID != 0 && HBillNo != "")
+                        if (j == SumDay-1 && SumCount == 0 && HInterID != 0 && HBillNo != "")
                         {
                             //LogService.CustomWriteLog("3:"+ HInterID+","+ HBillNo, DateTime.Now.ToString("yyyy-MM-dd"));
                             objJsonResult = AddBillSub(HInterID.ToString(), HBillNo, DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd").ToString()), 0, list[i]);
                         }
                     }
+
+                    LogService.CustomWriteLog("2.4:" + i, DateTime.Now.ToString("yyyy-MM-dd"));
 
                     if (TrueCount != SumCount)
                     {
@@ -333,10 +550,18 @@
                         objJsonResult.data = null;
                         return objJsonResult;
                     }
+
+                   
                 }
-             
+
+                LogService.CustomWriteLog("2.5:", DateTime.Now.ToString("yyyy-MM-dd"));
+
                 //鍚屾鏃ヨ鍒掑伐鍗�
                 oCN.RunProc("exec REALESE_SC_ICMOBILLSTATUS_TMP");
+
+                LogService.CustomWriteLog("2.6:", DateTime.Now.ToString("yyyy-MM-dd"));
+                sw.Stop();//缁撴潫璁℃椂
+                LogService.Write($"========================1.鎺掍骇璁㈠崟鎬荤敤鏃讹細" + sw.Elapsed);
 
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
@@ -356,30 +581,68 @@
 
         public json AddBillSub(string HInterID, string HBillNo, DateTime date, double HQTY, Dictionary<string, string> dic)
         {
+            string sReturn = "";
+            oSystemParameter.ShowBill(ref sReturn);
+
             //鑾峰彇琛ㄦ牸鏁版嵁
-            ds = oCN.RunProcReturn($"select * from  h_v_JIT_Sc_WorkBillSortBillList where 鍗曟嵁鍙�='{HBillNo}'", "h_v_JIT_Sc_WorkBillSortBillList");
+            ds = oCN.RunProcReturn($"select * from  h_v_JIT_Sc_WorkBillSortBill_PC where 鍗曟嵁鍙�='{HBillNo}'", "h_v_JIT_Sc_WorkBillSortBill_PC");
             int count = 0;
             if (ds.Tables[0].Rows.Count > 0)
             {
-                //鍒ゆ柇瀛愯〃鏄惁鏈夊綋鏃ョ殑鏃ユ湡浠ュ強鏃ユ湡鎵�瀵瑰簲鐨勬暟閲�
-                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
+                if (oSystemParameter.omodel.WMS_CampanyName == "娣诲悍绉戞妧") //绯荤粺鍙傛暟  瀹㈡埛瀹氬埗鍖栧悕绉�     绌虹櫧涓洪�氱敤
                 {
-                    if (DateTime.Parse(ds.Tables[0].Rows[i]["鏃ヨ鍒掔敓浜ф棩鏈�"].ToString()) == date)
+                    //鍒ゆ柇瀛愯〃鏄惁鏈夊綋鏃ョ殑鏃ユ湡浠ュ強鏃ユ湡鎵�瀵瑰簲鐨勬暟閲�
+                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                     {
-                        oCN.RunProc($"update Sc_WorkBillSortBillSub set HMasterDate='{date}',HQty={HQTY},HUseTimes={(dic["灏忔椂浜ц兘"]=="0"?0: HQTY / float.Parse(dic["灏忔椂浜ц兘"].ToString()))}" +
-                            $"  where HInterID={HInterID} and HEntryID={ds.Tables[0].Rows[i]["hsubid"].ToString()}");
-                        count += 1;
+                        if (DateTime.Parse(ds.Tables[0].Rows[i]["鏃ヨ鍒掔敓浜ф棩鏈�"].ToString()) == date)
+                        {
+                            oCN.RunProc($"update Sc_WorkBillSortBillSub set HMasterDate='{date}',HQty={HQTY},HUseTimes={(dic["浜х嚎鎬讳骇鑳�"] == "0" ? 0 : HQTY / float.Parse(dic["浜х嚎鎬讳骇鑳�"].ToString()))}" +
+                                $"  where HInterID={HInterID} and HEntryID={ds.Tables[0].Rows[i]["hsubid"].ToString()}");
+                            count += 1;
+                        }
                     }
                 }
+                else
+                {
+                    //鍒ゆ柇瀛愯〃鏄惁鏈夊綋鏃ョ殑鏃ユ湡浠ュ強鏃ユ湡鎵�瀵瑰簲鐨勬暟閲�
+                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
+                    {
+                        if (DateTime.Parse(ds.Tables[0].Rows[i]["鏃ヨ鍒掔敓浜ф棩鏈�"].ToString()) == date)
+                        {
+                            oCN.RunProc($"update Sc_WorkBillSortBillSub set HMasterDate='{date}',HQty={HQTY},HUseTimes={(dic["灏忔椂浜ц兘"] == "0" ? 0 : HQTY / float.Parse(dic["灏忔椂浜ц兘"].ToString()))}" +
+                                $"  where HInterID={HInterID} and HEntryID={ds.Tables[0].Rows[i]["hsubid"].ToString()}");
+                            count += 1;
+                        }
+                    }
+                }               
             }
-
+           
             if (count != 1)
             {
-                //鎻掑叆瀛愯〃
-                oCN.RunProc("insert into Sc_WorkBillSortBillSub(HInterID,HSEQ," +
-                    "HMasterDate,HQty,HUseTimes)" +
-                            $"values({HInterID}, {(ds.Tables[0].Rows.Count + 1)}," +
-                            $" '{date}', {HQTY},{(dic["灏忔椂浜ц兘"] == "0" ? 0 : HQTY / float.Parse(dic["灏忔椂浜ц兘"].ToString()))})");
+                if (oSystemParameter.omodel.WMS_CampanyName == "娣诲悍绉戞妧") //绯荤粺鍙傛暟  瀹㈡埛瀹氬埗鍖栧悕绉�     绌虹櫧涓洪�氱敤
+                {
+                    //鎻掑叆瀛愯〃
+                    oCN.RunProc("insert into Sc_WorkBillSortBillSub(HInterID,HSEQ," +
+                        "HMasterDate,HQty,HUseTimes)" +
+                                $"values({HInterID}, {(ds.Tables[0].Rows.Count + 1)}," +
+                                $" '{date}', {HQTY},{ ((dic["浜х嚎鎬讳骇鑳�"] == "0.0000" ? 0 : dic["浜х嚎鎬讳骇鑳�"] == "0" ? 0 : HQTY / float.Parse(dic["浜х嚎鎬讳骇鑳�"].ToString())).ToString() == "闈炴暟瀛�" ? 0 : dic["浜х嚎鎬讳骇鑳�"] == "0.0000" ? 0 : dic["浜х嚎鎬讳骇鑳�"] == "0" ? 0 : HQTY / float.Parse(dic["浜х嚎鎬讳骇鑳�"].ToString())) })");
+                }
+                else
+                {
+                    //鎻掑叆瀛愯〃
+                    oCN.RunProc("insert into Sc_WorkBillSortBillSub(HInterID,HSEQ," +
+                        "HMasterDate,HQty,HUseTimes)" +
+                                $"values({HInterID}, {(ds.Tables[0].Rows.Count + 1)}," +
+                                $" '{date}', {HQTY},{ ((dic["灏忔椂浜ц兘"] == "0.0000" ? 0 : dic["灏忔椂浜ц兘"] == "0" ? 0 : HQTY / float.Parse(dic["灏忔椂浜ц兘"].ToString())).ToString() == "闈炴暟瀛�" ? 0 : dic["灏忔椂浜ц兘"] == "0.0000" ? 0 : dic["灏忔椂浜ц兘"] == "0" ? 0 : HQTY / float.Parse(dic["灏忔椂浜ц兘"].ToString())) })");
+                }                         
+            }
+
+            
+            if (oSystemParameter.omodel.WMS_CampanyName == "娣诲悍绉戞妧") //绯荤粺鍙傛暟  瀹㈡埛瀹氬埗鍖栧悕绉�     绌虹櫧涓洪�氱敤
+            {
+                //鎶婃帓浜ц鍗曞畬宸ユ棩鏈熷弽鍐欏埌閲戣澏閿�鍞鍗曚笂
+                string sql = "exec h_p_JIT_UpdateEndDateToERP " + HInterID + ",'" + HBillNo + "'";
+                oCN.RunProc(sql);
             }
 
             objJsonResult.code = "1";
@@ -727,9 +990,9 @@
         }
         #endregion
 
-        [Route("JIT_DayPlanPlatFormBill/JIT_CompleteSetAnalysis")]
-        [HttpGet]
-        public object JIT_CompleteSetAnalysis(string sWhere, string user)
+        #region 榻愬鍒嗘瀽    鍘熻皟鐢ㄦ柟娉�
+
+        public object JIT_CompleteSetAnalysis_Old(string sWhere, string user)
         {
             try
             {
@@ -740,6 +1003,19 @@
                 //LogService.Write("榻愬鍒嗘瀽sql:" + sql);
                 List<PRD_PPBOM> BomList = new List<PRD_PPBOM>();
                 DataTable resulTable = ds.Tables[0];
+
+                if (ds.Tables[0].Rows.Count < 1 || ds == null)
+                {
+                    //閲婃斁榻愬鎿嶄綔 閬垮厤澶氫汉鍚屾椂杩涜榻愬鍒嗘瀽
+                    oCN.RunProc($"update T_PRD_QTFX set FSTATUS = 0 where FPRDORGID ={omdelMian.HProdORGID} and FSTATUS = 1 ");
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "娌℃湁闇�瑕佽繘琛岄綈濂楀垎鏋愮殑鏁版嵁";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 if (resulTable.Rows[0][0].ToString().Contains("澶辫触"))
                 {
                     //閲婃斁榻愬鎿嶄綔 閬垮厤澶氫汉鍚屾椂杩涜榻愬鍒嗘瀽
@@ -781,9 +1057,10 @@
                 sw.Start();//寮�濮嬭鏃�
 
                 //鑾峰彇褰撳墠鍗虫椂搴撳瓨 搴撳瓨鏁伴噺+搴撳瓨缁勭粐+鐗╂枡+璐т富+浠撳簱   
+                //鍘熸煡璇㈠嵆鏃跺簱瀛樻柟寮忥細select * from h_v_jit_InventoryList
                 ds = oCN.RunProcReturn(@" 
-select * from h_v_jit_InventoryList
-", "h_v_jit_InventoryList");
+exec h_p_jit_Inventory_UsableList
+", "h_p_jit_Inventory_UsableList");
                 ListInventory = ds.ToModelList<PRD_Inventory>();
                 //杞﹂棿 浠撳簱瀵圭収鍒楄〃 
                 ds = oCN.RunProcReturn(@" 
@@ -1162,6 +1439,103 @@
                 return objJsonResult;
             }
         }
+
+        #endregion
+
+        #region 榻愬鍒嗘瀽璋冪敤鏂规硶    20250402
+
+        [Route("JIT_DayPlanPlatFormBill/JIT_CompleteSetAnalysis")]
+        [HttpGet]
+        public object JIT_CompleteSetAnalysis(string sWhere, string user)
+        {
+            try
+            {
+                string sErrMsg = "";
+                if (oSystemParameter.ShowBill(ref sErrMsg) == true)
+                {
+                    if (oSystemParameter.omodel.WMS_CampanyName == "甯呭▉"
+                        || oSystemParameter.omodel.WMS_CampanyName == "鍑礉濂堢壒"
+                        || oSystemParameter.omodel.WMS_CampanyName == "娣诲悍绉戞妧"
+                        || oSystemParameter.omodel.WMS_CampanyName == "瀹濆伐")     //绯荤粺鍙傛暟  瀹㈡埛瀹氬埗鍖栧悕绉�     绌虹櫧涓洪�氱敤
+                    {
+                        objJsonResult = (json)JIT_CompleteSetAnalysis_Old(sWhere, user);
+                    }
+                    else
+                    {
+                        objJsonResult = (json)JIT_CompleteSetAnalysis_New(sWhere, user);
+                    }
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鑾峰彇绯荤粺鍙傛暟澶辫触锛� " + sErrMsg;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                LogService.Write("榻愬鍒嗘瀽鎿嶄綔澶辫触锛�" + e.Message.ToString());
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.Message.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        /// <summary>
+        /// 榻愬鍒嗘瀽    鏂拌皟鐢ㄦ柟娉�
+        /// </summary>
+        /// <returns></returns>
+        public object JIT_CompleteSetAnalysis_New(string sWhere, string user)
+        {
+            try
+            {
+                omdelMian = JsonConvert.DeserializeObject<Sc_WorkBillSortBillMain>(sWhere);
+                string HWorkShopID = omdelMian.HWorkShopID.ToString();
+                var HStockOrgID = omdelMian.HProdORGID;
+
+                ds = oCN.RunProcReturn("exec h_p_JIT_CompleteSetAnalysis " + HWorkShopID.ToString() + ",'" + user + "'," + HStockOrgID.ToString(), "h_p_JIT_CompleteSetAnalysis");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "榻愬鍒嗘瀽鍙戠敓閿欒锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) == 1)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);    //杩愮畻鎴愬姛
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "榻愬鍒嗘瀽澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        #endregion
+
         #endregion
 
         #region 鐢熶骇鏃ヨ鍒掑钩鍙� 鎻愭枡杩愮畻
@@ -1527,6 +1901,7 @@
                 string fProWorkShopId = omdelMian.HWorkShopID.ToString();
                 var fPrdOrgId = omdelMian.HProdORGID;
                 string sqlName = "";//AIS20210811135644
+                string WMS_CampanyName = "";    //瀹㈡埛鍚嶇О
                 //瀹㈡埛鍒跺畾
                 string sErr = "";
                 if (oSystemParameter.ShowBill(ref sErr))
@@ -1534,27 +1909,58 @@
                     if (oSystemParameter.omodel.WMS_CampanyName == "甯呭▉")
                     {
                         sqlName = "AIS20230129011339";
+                        WMS_CampanyName = "甯呭▉";
                     }
                     else if (oSystemParameter.omodel.WMS_CampanyName == "鍑礉濂堢壒")
                     {
                         sqlName = "AIS20210820164804";
+                        WMS_CampanyName = "鍑礉濂堢壒";
+                    }
+                    else if (oSystemParameter.omodel.WMS_CampanyName == "娣诲悍绉戞妧")
+                    {
+                        sqlName = "AIS20240809105013";
+                        WMS_CampanyName = "娣诲悍绉戞妧";
+                    }
+                    else if (oSystemParameter.omodel.WMS_CampanyName == "瀹濆伐")
+                    {
+                        sqlName = "AIS20250102123554";
+                        WMS_CampanyName = "瀹濆伐";
                     }
                     else
                     {
                         sqlName = "AIS20210811135644";
                     }
-                }
 
-                if (HTLType == "缂烘枡")
-                {
-                    objJsonResult = (json)JIT_QL(fProWorkShopId, fPrdOrgId, user, sqlName);
-                }
-                else if (HTLType == "鐢熶骇鐢ㄦ枡娓呭崟")
-                {
-                 objJsonResult=(json)JIT_PPBOM(fProWorkShopId, fPrdOrgId, user, sqlName);
-                }
+                    if (WMS_CampanyName == "瀹濆伐")
+                    {
+                        objJsonResult = (json)JIT_MOMaterLack(fProWorkShopId, fPrdOrgId, user);
+                    }
+                    else if (HTLType == "缂烘枡")
+                    {
+                        if (WMS_CampanyName == "甯呭▉" || WMS_CampanyName == "鍑礉濂堢壒" || WMS_CampanyName == "娣诲悍绉戞妧")
+                        {
+                            objJsonResult = (json)JIT_QL(fProWorkShopId, fPrdOrgId, user, sqlName);
+                        }
+                        else
+                        {
+                            objJsonResult = (json)JIT_MOMaterReady(fProWorkShopId, fPrdOrgId, user);
+                        }
+                    }
+                    else if (HTLType == "鐢熶骇鐢ㄦ枡娓呭崟")
+                    {
+                        objJsonResult = (json)JIT_PPBOM(fProWorkShopId, fPrdOrgId, user, sqlName);
+                    }
 
-                return objJsonResult;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鑾峰彇绯荤粺鍙傛暟澶辫触锛� " + sErr;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
             }
             catch (Exception e)
             {
@@ -2476,6 +2882,145 @@
                 return objJsonResult;
             }
         }
+
+        /// <summary>
+        /// 閫氳繃娆犳枡琛�   绠楁彁鏂� 瀹濆伐
+        /// </summary>
+        /// <returns></returns>
+        public object JIT_MOMaterLack(string HWorkShopID, int? HProdORGID, string user)
+        {
+            try
+            {
+                ds = oCN.RunProcReturn("exec h_p_JIT_PODemandPlanBill_MOMaterLack " + HWorkShopID.ToString() + ",'" + user + "'," + HProdORGID.ToString(), "h_p_JIT_PODemandPlanBill_MOMaterLack");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎻愭枡杩愮畻鍙戠敓閿欒锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) == 1)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);    //杩愮畻鎴愬姛
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎻愭枡杩愮畻澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        /// <summary>
+        /// 閫氳繃榻愬琛�   绠楁彁鏂�
+        /// </summary>
+        /// <returns></returns>
+        public object JIT_MOMaterReady(string HWorkShopID, int? HProdORGID, string user)
+        {
+            try
+            {
+                ds = oCN.RunProcReturn("exec h_p_JIT_PODemandPlanBill_MOMaterReady " + HWorkShopID.ToString() + ",'" + user + "'," + HProdORGID.ToString(), "h_p_JIT_PODemandPlanBill_MOMaterReady");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎻愭枡杩愮畻鍙戠敓閿欒锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) == 1)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);    //杩愮畻鎴愬姛
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎻愭枡杩愮畻澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        #endregion
+
+        #region 鐢熶骇鏃ヨ鍒掑钩鍙� 瑕佹枡杩愮畻
+
+        [Route("JIT_DayPlanPlatFormBill/JIT_YLYS")]
+        [HttpGet]
+        public object JIT_YLYS(string sWhere, string user)
+        {
+            try
+            {
+                omdelMian = JsonConvert.DeserializeObject<Sc_WorkBillSortBillMain>(sWhere);
+                string HWorkShopID = omdelMian.HWorkShopID.ToString();
+                var HStockOrgID = omdelMian.HProdORGID;
+
+                ds = oCN.RunProcReturn("exec h_p_JIT_WorkDemandPlanBill_MOMaterReady " + HWorkShopID.ToString() + ",'" + user + "'," + HStockOrgID.ToString(), "h_p_JIT_WorkDemandPlanBill_MOMaterReady");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "瑕佹枡杩愮畻鍙戠敓閿欒锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) == 1)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);    //杩愮畻鎴愬姛
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "瑕佹枡杩愮畻澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
         #endregion
 
         #region 鐢熶骇鏃ヨ鍒掑钩鍙� 閿佸畾
@@ -2536,6 +3081,58 @@
         }
         #endregion
 
+        #region 鐢熶骇鏃ヨ鍒掑钩鍙� 閿佸畾宸ュ崟
+        [Route("JIT_DayPlanPlatFormBill/JIT_DayPlanPlatFormBillHLockedOrder")]
+        [HttpGet]
+        public object JIT_DayPlanPlatFormBillHLockedOrder(string HInterIDs)
+        {
+            try
+            {
+                oCN.RunProc($"update Sc_WorkBillSortBillMain set HLockOrder = 1 where HInterID in ({HInterIDs})");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢熶骇鏃ヨ鍒掑钩鍙� 瑙i攣宸ュ崟
+        [Route("JIT_DayPlanPlatFormBill/JIT_DayPlanPlatFormBillHUnlockOrder")]
+        [HttpGet]
+        public object JIT_DayPlanPlatFormBillHUnlockOrder(string HInterIDs)
+        {
+            try
+            {
+                oCN.RunProc($"update Sc_WorkBillSortBillMain set HLockOrder = 0 where HInterID in ({HInterIDs})");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         #region 鐢熶骇鏃ヨ鍒掑钩鍙� 鐢熶骇璁㈠崟鏌ヨ
         [Route("JIT_DayPlanPlatFormBill/JIT_ICMOBillList")]
         [HttpGet]
@@ -2557,7 +3154,7 @@
                     {
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
-                        objJsonResult.Message = "鐢熶骇鏄庣粏琛岄噸澶�,閲嶅鐨勭敓浜ц鍗曞彿:" + ds.Tables[0].Rows[i]["鐢熶骇璁㈠崟鍙�"].ToString() + ",鏄庣粏琛屽彿:" + ds.Tables[0].Rows[i]["鐢熶骇璁㈠崟鏄庣粏琛屽彿"].ToString();
+                        objJsonResult.Message = "鐢熶骇鏄庣粏琛岄噸澶�,閲嶅鐨勭敓浜ц鍗曞彿:" + dt.Tables[0].Rows[i]["鐢熶骇璁㈠崟鍙�"].ToString() + ",鏄庣粏琛屽彿:" + dt.Tables[0].Rows[i]["鐢熶骇璁㈠崟鏄庣粏琛屽彿"].ToString();
                         objJsonResult.data = null;
                         return objJsonResult;
                     }
@@ -2647,6 +3244,74 @@
                     else
                     {
                         DataRow dr = dt.NewRow();
+                        dr["灏忔椂浜ц兘"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["浜ц兘"]);
+                        dr["鐢熶骇鍛ㄦ湡"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["鐢熶骇鍛ㄦ湡"]);
+                        dr["寮�宸ヤ綑閲�"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["寮�宸ヤ綑閲�"]);
+                        dr["鏈�杩熷紑宸ユ棩鏈�"] = DBUtility.ClsPub.isDate(ds.Tables[0].Rows[0]["鏈�杩熷紑宸ユ棩鏈�"]);
+                        dr["鏈�杩熷畬宸ユ棩鏈�"] = DBUtility.ClsPub.isDate(ds.Tables[0].Rows[0]["鏈�杩熷畬宸ユ棩鏈�"]);
+                        dr["璁㈠崟闇�姹傛暟閲�"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["璁㈠崟闇�姹傛暟"]);
+                        dr["璁㈠崟浜よ揣鏈�"] = DBUtility.ClsPub.isDate(ds.Tables[0].Rows[0]["璁㈠崟浜よ揣鏈�"]);
+                        dr["HICMOInterID"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["HICMOInterID"]);
+                        dr["HICMOEntryID"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["HICMOEntryID"]);
+                        dt.Rows.Add(dr);
+                    }
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = dt;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢熶骇鏃ヨ鍒掑钩鍙� 鏁版嵁鍑嗗 璁剧疆浠诲姟鍗曠浉鍏充俊鎭�(涓夊崌)
+        [Route("JIT_DayPlanPlatFormBill/ReadyData_SS")]
+        [HttpGet]
+        public object ReadyData_SS(string SWhere)
+        {
+            try
+            {
+                var list = SWhere.Split(',');
+                DataTable dt = new DataTable("date");
+                dt.Columns.Add("HICMOInterID", typeof(string));
+                dt.Columns.Add("HICMOEntryID", typeof(string));
+                dt.Columns.Add("灏忔椂浜ц兘", typeof(string));
+                dt.Columns.Add("鐢熶骇鍛ㄦ湡", typeof(decimal));
+                dt.Columns.Add("寮�宸ヤ綑閲�", typeof(decimal));
+                dt.Columns.Add("鏈�杩熷紑宸ユ棩鏈�", typeof(DateTime));
+                dt.Columns.Add("鏈�杩熷畬宸ユ棩鏈�", typeof(DateTime));
+                dt.Columns.Add("璁㈠崟闇�姹傛暟閲�", typeof(decimal));
+                dt.Columns.Add("璁㈠崟浜よ揣鏈�", typeof(DateTime));
+                dt.Columns.Add("HSourceID", typeof(decimal));
+                dt.Columns.Add("鐢熶骇璧勬簮", typeof(string));
+
+                for (int i = 0; i < list.Length; i++)
+                {
+                    string HICMOInterID = list[i].Split(';')[0].ToString();
+                    string HICMOEntryID = list[i].Split(';')[1].ToString();
+                    string HSourceID = list[i].Split(';')[2].ToString();
+
+                    Thread.Sleep(100);
+                    ds = oCN.RunProcReturn("exec h_p_Sc_GetInfoByICMOBillNo " + HICMOInterID + "," + HICMOEntryID + "," + HSourceID, "h_p_Sc_GetInfoByICMOBillNo");
+                    if (ds == null || ds.Tables[0].Rows.Count == 0)
+                    {
+
+                    }
+                    else
+                    {
+                        DataRow dr = dt.NewRow();
+                        dr["HSourceID"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["HSourceID"]);
+                        dr["鐢熶骇璧勬簮"] = ds.Tables[0].Rows[0]["鐢熶骇璧勬簮"].ToString();
                         dr["灏忔椂浜ц兘"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["浜ц兘"]);
                         dr["鐢熶骇鍛ㄦ湡"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["鐢熶骇鍛ㄦ湡"]);
                         dr["寮�宸ヤ綑閲�"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["寮�宸ヤ綑閲�"]);
@@ -2768,5 +3433,306 @@
             }
         }
         #endregion
+
+        #region 鐢熶骇鏃ヨ鍒掑钩鍙� 鏍规嵁杞﹂棿娣诲姞鏈帓浜х敓浜ц鍗�
+        [Route("JIT_DayPlanPlatFormBill/JIT_ICMOBillListByDept")]
+        [HttpGet]
+        public object JIT_ICMOBillListByDept(string HDeptID)
+        {
+            try
+            {
+                //鑾峰彇鏄剧ず绯荤粺鍙傛暟
+                string sReturn = "";
+                oSystemParameter.ShowBill(ref sReturn);
+
+                //鏌ヨ閫夋嫨杞﹂棿涓湭鎺掍骇杩囩殑鐢熶骇璁㈠崟淇℃伅锛堟坊搴风鎶�--鐢熶骇璁㈠崟鐘舵�佷负涓嬭揪锛�
+                ds = oCN.RunProcReturn($"exec h_p_JIT_ICMOBillListByDept '{HDeptID}'", "h_p_JIT_ICMOBillListByDept");
+
+                if (ds.Tables[0].Rows.Count > 0 && ds != null)
+                {
+                    if (oSystemParameter.omodel.WMS_CampanyName == "娣诲悍绉戞妧") //绯荤粺鍙傛暟  瀹㈡埛瀹氬埗鍖栧悕绉�     绌虹櫧涓洪�氱敤
+                    {
+                        //鏁版嵁琛ㄦ牸娣诲姞鍔ㄦ�佹棩鏈�
+                        for (int j = 1; j <= 180; j++)
+                        {
+                            ds.Tables[0].Columns.Add(DateTime.Now.AddDays(j - 1).ToString("yyyy-MM-dd"), typeof(Int32));
+                        }
+                    }
+                    else
+                    {
+                        //鏁版嵁琛ㄦ牸娣诲姞鍔ㄦ�佹棩鏈�
+                        for (int j = 1; j <= 31; j++)
+                        {
+                            ds.Tables[0].Columns.Add(DateTime.Now.AddDays(j - 1).ToString("yyyy-MM-dd"), typeof(Int32));
+                        }
+                    }                   
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "Sucess锛�";
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏌ユ棤鏁版嵁锛屽綋鍓嶆墍閫夎溅闂翠笅鏆傛棤鏈帓浜т笖璁㈠崟鐘舵�佷负涓嬭揪鐨勭敓浜ц鍗曚俊鎭紒";
+                    objJsonResult.data = "";
+                    return objJsonResult;
+                }
+               
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢熶骇鏃ヨ鍒掑钩鍙� 鑾峰彇瀹屽伐鏃ユ湡
+        [Route("JIT_DayPlanPlatFormBill/GetICMOCompletionDate")]
+        [HttpGet]
+        public object GetICMOCompletionDate(string HDeptID)
+        {
+            try
+            {
+                //鏇存柊鏃ヨ鍒掑伐鍗曠殑瀹屽伐鏃ユ湡
+                oCN.RunProc($"exec h_p_JIT_GetICMOCompletionDate '{HDeptID}'");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鑾峰彇瀹屽伐鏃ユ湡鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢熶骇鏃ヨ鍒掑钩鍙� 鑾峰彇鏈�鏃╁紑宸ユ棩鏈�
+        [Route("JIT_DayPlanPlatFormBill/GetICMOEarlyDate")]
+        [HttpGet]
+        public object GetICMOEarlyDate(string HDeptID)
+        {
+            try
+            {
+                //鏇存柊鐢熶骇璁㈠崟鐨勬渶鏃╁紑宸ユ棩鏈�
+                oCN.RunProc($"exec h_p_JIT_GetICMOEarlyDate '{HDeptID}'");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鑾峰彇鏈�鏃╁紑宸ユ棩鏈熸垚鍔燂紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 閫氳繃鐗╂枡鍖归厤浜у搧鍣ㄥ叿娓呭崟
+        [Route("JIT_DayPlanPlatFormBill/GetMouldByMater")]
+        [HttpGet]
+        public object GetMouldByMater(string HMaterID,string HSourceID,string HPCDate)
+        {
+            try
+            {
+                ds = oCN.RunProcReturn("exec h_p_Gy_MaterialMouldByMater " + HMaterID + "," + HSourceID + ",'" + HPCDate + "'", "h_p_Gy_MaterialMouldByMater");               
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                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 閫氳繃璧勬簮鍖归厤璧勬簮鍣ㄥ叿娓呭崟
+        [Route("JIT_DayPlanPlatFormBill/GetMouldBySource")]
+        [HttpGet]
+        public object GetMouldBySource(string HSourceID, string HMouldID)
+        {
+            try
+            {
+                ds = oCN.RunProcReturn("select * from h_v_Gy_SourceMouldBillMainList where HSourceID = " + HSourceID + " and HMouldID = " + HMouldID, "h_v_Gy_SourceMouldBillMainList");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                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 鎺掍骇鍚庡皢鍣ㄥ叿鍗犵敤鏃堕棿鍐欏叆鏁版嵁搴�
+        [Route("JIT_DayPlanPlatFormBill/AddMouldOccupancyTime")]
+        [HttpGet]
+        public object AddMouldOccupancyTime(string HMouldID, string HSourceID, string HICMOInterID, string HICMOEntryID, string HICMOBillNo, string HMouldPCTime)
+        {
+            try
+            {
+                ds = oCN.RunProcReturn("exec h_p_JIT_AddMouldOccupancyTime " + HMouldID + "," + HSourceID + "," + HICMOInterID + "," + HICMOEntryID + ",'" + HICMOBillNo  + "','" + HMouldPCTime + "'", "h_p_JIT_AddMouldOccupancyTime");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = "";
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 閫氳繃涓昏祫婧愬尮閰嶅瓙璧勬簮
+        [Route("JIT_DayPlanPlatFormBill/GetChildSource")]
+        [HttpGet]
+        public object GetChildSource(string HSourceID)
+        {
+            try
+            {
+                ds = oCN.RunProcReturn("select HItemID 瀛愯祫婧怚D,HNumber 瀛愯祫婧愪唬鐮�,HName 瀛愯祫婧愬悕绉�,HCubicleQty 瀛愯祫婧愬伐浣嶆暟 from Gy_Source with(nolock) where HParentID = " + HSourceID + " order by HName asc", "Gy_Source");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                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 鍒ゆ柇鐗╂枡鏄惁鍙互鏀惧湪鍚屼竴璧勬簮涓婁竴璧风敓浜�
+        [Route("JIT_DayPlanPlatFormBill/GetSourceByMater")]
+        [HttpGet]
+        public object GetSourceByMater(string HMaterID)
+        {
+            try
+            {
+                ds = oCN.RunProcReturn("exec h_p_Sc_ICMOGetWorkSource_TK " + HMaterID + ",'',''", "h_p_Sc_ICMOGetWorkSource_TK");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                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>
+        /// 杩斿洖椤圭洰闃舵鍒楄〃
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("JIT_DayPlanPlatFormBill/JIT_FuHeFenXiReport")]
+        [HttpGet]
+        public object JIT_FuHeFenXiReport(string sWhere, string user)
+        {
+            try
+            {
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("JIT_FuHeFenXiReport", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                List<object> columnNameList = new List<object>();
+                string sql = "exec h_p_JIT_FuHeFenXiReport   '" + sWhere + "','" + user + "'";
+
+                ds = oCN.RunProcReturn(sql, "h_p_JIT_FuHeFenXiReport");
+
+                //娣诲姞鍒楀悕
+                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 = 1;
+                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
+
+        
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1