From f34c6a21dc58bc0d40a011d6d7366c5eb3f15f15 Mon Sep 17 00:00:00 2001
From: yxj <yxj@hz-kingdee.com>
Date: 星期五, 20 九月 2024 13:59:34 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/SCGL/日计划管理/JIT_DayPlanPlatFormBillController.cs |  166 +++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 143 insertions(+), 23 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 b1d5c3c..6d87834 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"
@@ -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 鐢熶骇鏃ヨ鍒掑钩鍙� 淇濆瓨
@@ -160,7 +194,7 @@
 
                 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"));
                 for (int i = 0; i < list.Count; i++)
                 {
                     TrueCount = 0;
@@ -169,6 +203,7 @@
                     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,13 +213,14 @@
                         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();
                         var HSplitQty = list[i]["鎷嗗崟鏁伴噺"].ToString();
                         var HDayPlanSumQty = list[i]["鏃ヨ鍒掓暟閲忔�婚噺"].ToString();
                         var HPlanBeginDate = list[i]["璁″垝寮�濮嬫棩鏈�"].ToString();
+                        var HPlanEndDate = list[i]["璁″垝缁撴潫鏃ユ湡"].ToString();
                         var HSeOrderBillNo = list[i]["閿�鍞鍗曞彿"].ToString();
                         var HICMOBillType = list[i]["鐢熶骇璁㈠崟鍗曟嵁绫诲瀷"].ToString();
                         var HSourceStockInQty = list[i]["浜х嚎鍏ュ簱鏁伴噺"].ToString();
@@ -193,6 +229,9 @@
                         var HMainSourceInterID = list[i]["婧愬崟涓诲唴鐮�"].ToString();
                         var HMainSourceEntryID = list[i]["婧愬崟瀛愬唴鐮�"].ToString();
                         var HPlanQty = list[i]["璁″垝鏁伴噺"].ToString();
+                        var HEmpID = list[i]["HEmpID"].ToString();
+
+                        LogService.CustomWriteLog("2.05:" + i, DateTime.Now.ToString("yyyy-MM-dd"));
 
                         if (HSourceID == ""|| HSourceID == "0")
                         {
@@ -203,7 +242,7 @@
                             return objJsonResult;
                         }
 
-                        ds = oCN.RunProcReturn($"select * from  Sc_WorkBillSortBillMain where HMainSourceInterID={HMainSourceInterID}" +
+                        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 > 0)
                         {
@@ -225,7 +264,7 @@
                             " HOrderNeedQty, HSplitQty, HDayPlanSumQty,HPlanBeginDate," +
                             "HSeOrderBillNo,HICMOBillType,HSourceStockInQty,HLeftPlanQty,HOrderLev,HPreparatDate," +
                             "HMainSourceInterID,HMainSourceEntryID,HICMOInterID_Sec,HICMOEntryID_Sec,HPlanQty" +
-                            ",HICMOInterID,HICMOEntryID)values" +
+                            ",HICMOInterID,HICMOEntryID,HPlanEndDate,HEmpID)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)}," +
@@ -233,7 +272,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})";
+                            $"{HMainSourceInterID},{HMainSourceEntryID},'{HPlanEndDate}','{HEmpID}')";
 
                         //LogService.Write("sql:" + sql);
                         //涓昏〃
@@ -241,6 +280,9 @@
                     }
                     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();
                         var HMainSourceEntryID = list[i]["婧愬崟瀛愬唴鐮�"].ToString();
                         var HICMOBillNo = list[i]["鐢熶骇璁㈠崟鍙�"].ToString();
@@ -254,6 +296,10 @@
                         var HLastEndDate = list[i]["鏈�杩熷畬宸ユ棩鏈�"].ToString();
                         var HOrderNeedQty = list[i]["璁㈠崟闇�姹傛暟閲�"].ToString();
                         var HOrderCommitDate = list[i]["璁㈠崟浜よ揣鏈�"].ToString();
+                        var HPlanEndDate = list[i]["璁″垝缁撴潫鏃ユ湡"].ToString();
+                        var HSplitQty = list[i]["鎷嗗崟鏁伴噺"].ToString();
+
+                        LogService.CustomWriteLog("2.1:"+i, DateTime.Now.ToString("yyyy-MM-dd"));
 
                         if (HSourceID == "" || HSourceID == "0")
                         {
@@ -278,16 +324,20 @@
 
                         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}'" +
+                            $",HLastEndDate='{HLastEndDate}',HOrderNeedQty={HOrderNeedQty},HOrderCommitDate='{HOrderCommitDate}',HPlanEndDate='{HPlanEndDate}',HSplitQty={HSplitQty}" +
                             $" where HInterID={list[i]["hmainid"].ToString()} and HBillNo='{list[i]["鍗曟嵁鍙�"].ToString()}'");
                     }
 
@@ -295,6 +345,7 @@
 
                     int SumDay = 31; //鍔ㄦ�佷袱鏈堜箣宸� DateTime.Now.AddMonths(1).AddDays(-1).Subtract(DateTime.Now).Days;
 
+                    LogService.CustomWriteLog("2.3:" + i, DateTime.Now.ToString("yyyy-MM-dd"));
                     for (int j = 0; j < SumDay; j++)
                     {
                         //涓昏〃瀛愯〃閮芥湁鏁版嵁
@@ -305,7 +356,7 @@
                             objJsonResult = AddBillSub(HInterID == 0 ? list[i]["hmainid"].ToString() : HInterID.ToString()
                                 , HBillNo == "" ? list[i]["鍗曟嵁鍙�"].ToString() : HBillNo
                                  , DateTime.Parse(DateTime.Now.AddDays(j).ToString("yyyy-MM-dd").ToString())
-                                 , int.Parse(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)
                                  , list[i]);
                             if (objJsonResult.count == 1)
                             {
@@ -315,22 +366,29 @@
                         //涓昏〃鏈夋暟鎹� 瀛愯〃鏃犳暟鎹�
                         if (j == 30 && 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)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = objJsonResult.Message;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
                 }
 
-                if (TrueCount != SumCount)
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = objJsonResult.Message;
-                    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"));
 
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
@@ -348,8 +406,8 @@
             }
         }
 
-        public json AddBillSub(string HInterID, string HBillNo, DateTime date, int HQTY, Dictionary<string, string> dic)
-        {
+        public json AddBillSub(string HInterID, string HBillNo, DateTime date, double HQTY, Dictionary<string, string> dic)
+        {         
             //鑾峰彇琛ㄦ牸鏁版嵁
             ds = oCN.RunProcReturn($"select * from  h_v_JIT_Sc_WorkBillSortBillList where 鍗曟嵁鍙�='{HBillNo}'", "h_v_JIT_Sc_WorkBillSortBillList");
             int count = 0;
@@ -366,14 +424,14 @@
                     }
                 }
             }
-
+           
             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()))})");
+                            $" '{date}', {HQTY},{ ( (dic["灏忔椂浜ц兘"] == "0.0000" ? 0 : HQTY / float.Parse(dic["灏忔椂浜ц兘"].ToString())).ToString()=="闈炴暟瀛�" ? 0 : dic["灏忔椂浜ц兘"] == "0.0000" ? 0 : HQTY / float.Parse(dic["灏忔椂浜ц兘"].ToString())) })");               
             }
 
             objJsonResult.code = "1";
@@ -1529,6 +1587,10 @@
                     {
                         sqlName = "AIS20230129011339";
                     }
+                    else if (oSystemParameter.omodel.WMS_CampanyName == "鍑礉濂堢壒")
+                    {
+                        sqlName = "AIS20210820164804";
+                    }
                     else
                     {
                         sqlName = "AIS20210811135644";
@@ -2547,7 +2609,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;
                     }
@@ -2606,11 +2668,11 @@
         #region 鐢熶骇鏃ヨ鍒掑钩鍙� 鏁版嵁鍑嗗 璁剧疆浠诲姟鍗曠浉鍏充俊鎭�
         [Route("JIT_DayPlanPlatFormBill/ReadyData")]
         [HttpGet]
-        public object ReadyData(string HICOMNum)
+        public object ReadyData(string SWhere)
         {
             try
             {
-                var list = HICOMNum.Split(',');
+                var list = SWhere.Split(',');
                 DataTable dt = new DataTable("date");
                 dt.Columns.Add("HICMOInterID", typeof(string));
                 dt.Columns.Add("HICMOEntryID", typeof(string));
@@ -2626,9 +2688,10 @@
                 {
                     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, "h_p_Sc_GetInfoByICMOBillNo");
+                    ds = oCN.RunProcReturn("exec h_p_Sc_GetInfoByICMOBillNo " + HICMOInterID+","+ HICMOEntryID+","+ HSourceID, "h_p_Sc_GetInfoByICMOBillNo");
                     if (ds == null || ds.Tables[0].Rows.Count == 0)
                     {
                         
@@ -2700,5 +2763,62 @@
         }
         #endregion
 
+        #region 鏍规嵁鐗╂枡ID鑾峰彇宸ヨ壓璺嚎 鍒楄〃
+        [Route("JIT_DayPlanPlatFormBill/GetRoutingListByMater")]
+        [HttpGet]
+        public object GetRoutingListByMater(int HMaterID, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                int IsHavingPermissions = 1;
+
+                //鍒ゆ柇鏄惁鏈夊伐鑹鸿矾绾跨紪杈戞潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Gy_RoutingBill_Edit", 1, false, user))
+                {
+                    IsHavingPermissions = 0;
+                }
+
+                ds = oCN.RunProcReturn("select * from  h_v_JIT_GetRoutingList_Mater where HMaterID = " + HMaterID , "h_v_JIT_GetRoutingList_Mater");
+
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "褰撳墠鐗╂枡娌℃湁缁存姢宸ヨ壓璺嚎锛佽鑱旂郴璁″垝閮ㄨ繘琛岀淮鎶�";
+                    objJsonResult.data = ds.Tables[0];
+                    objJsonResult.IsHavingPermissions = IsHavingPermissions;
+                    return objJsonResult;
+                }
+                else
+                {
+                    //娣诲姞鍒楀悕
+                    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;
+                    objJsonResult.IsHavingPermissions = IsHavingPermissions;
+                    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