From d6e06131e35528e02e34de459565c26693a643a7 Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期一, 26 五月 2025 19:13:11 +0800
Subject: [PATCH] 提料齐套报表添加多选组织功能

---
 WebAPI/Controllers/SCGL/日计划管理/JIT_DayPlanPlatFormImportController.cs | 1159 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1,149 insertions(+), 10 deletions(-)

diff --git "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormImportController.cs" "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormImportController.cs"
index 9705a9f..62b64b5 100644
--- "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormImportController.cs"
+++ "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormImportController.cs"
@@ -1,11 +1,15 @@
-锘縰sing System;
+锘縰sing Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
 using System.Collections.Generic;
 using System.Data;
+using System.IO;
 using System.Linq;
 using System.Web;
 using System.Web.Http;
+using System.Web.Script.Serialization;
 using WebAPI.Models;
-
+using System.Globalization;
 namespace WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�
 {
     public class JIT_DayPlanPlatFormImportController : ApiController
@@ -14,25 +18,249 @@
         public DataSet ds = new DataSet();
         public WebServer webserver = new WebServer();
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+        public static string BillType = "4610";
+        Sc_WorkBillSortBillMain omdelMian = new Sc_WorkBillSortBillMain();
+        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
 
-        #region 鐢熶骇鏃ヨ鍒掑鍏�
+
+        #region 鐢熶骇鏃ヨ鍒� 鏂囦欢涓婁紶
         [Route("JIT_DayPlanPlatFormImport/JIT_DayPlanPlatFormImport_DR")]
         [HttpPost]
-        public object JIT_DayPlanPlatFormImport_DR(HttpPostedFileBase file)
+        public object JIT_DayPlanPlatFormImport_DR()
         {
             try
             {
-                if (file != null)
+                //鑾峰彇鏂囦欢鍚嶇О
+                var file = HttpContext.Current.Request.Files[0];
+                //鑾峰彇鏂囦欢鐗╃悊璺緞
+                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
+                //淇濆瓨鏂囦欢
+                file.SaveAs(ExcelPath);
+
+                NpoiHelper np = new NpoiHelper();
+                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1,1,"0");
+
+                //鍒犻櫎鏂囦欢
+                File.Delete(ExcelPath);
+
+                //鍒涘缓涓存椂琛�
+                DataTable tb2 = new DataTable("dt2");
+
+                //娣诲姞鍒楀悕
+                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
                 {
-                    NpoiHelper np = new NpoiHelper();
-                    DataSet ds = np.ReadExcel(@"C:\Users\Harold\Desktop\鏂板缓XLS宸ヤ綔琛�.xls", 1);
-                    DataTable dt = ds.Tables[0];
+                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
+                }
+                //妯℃澘缂哄皯鍒� 浣嗛渶瑕佷粠鏁版嵁搴撲腑鏌ヨ鍑烘潵鏄剧ず鍦ㄩ〉闈㈢殑瀛楁
+                tb2.Columns.Add("hmainid", typeof(Int32));
+                tb2.Columns.Add("HMaterID", typeof(Int32));//鐗╂枡ID
+                tb2.Columns.Add("鍗曟嵁鍙�", typeof(string));
+                tb2.Columns.Add("HWorkShopID", typeof(Int32));//鐢熶骇杞﹂棿
+                tb2.Columns.Add("HEmpID", typeof(Int32));//鑱屽憳
+                tb2.Columns.Add("鍛樺伐", typeof(string));//鑱屽憳
+                tb2.Columns.Add("HUnitID", typeof(Int32));//璁¢噺鍗曚綅
+                tb2.Columns.Add("HSourceID", typeof(Int32));//鐢熶骇璧勬簮id
+                tb2.Columns.Add("ICMOBillHInterID", typeof(Int32));//鐢熶骇璁㈠崟涓籭d
+                tb2.Columns.Add("ICMOBillHEntryID", typeof(Int32));//鐢熶骇璁㈠崟瀛恑d
+                tb2.Columns.Add("HProdORGID", typeof(Int32));//缁勭粐id
+                tb2.Columns.Add("HSeOrderBillNo", typeof(string));//閿�鍞鍗曞彿                
+
+                //鑾峰彇绯荤粺鍙傛暟
+                string Ret = "";
+                oSystemParameter.ShowBill(ref Ret);
+
+                LogService.Write("excel鍊硷細" + ExcelDs.Tables[0].Rows[1][15].ToString());//2024-11-26
+                //娣诲姞鏁版嵁
+                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
+                {                  
+                    DataRow row = tb2.NewRow();
+                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
+                    {
+                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
+                    }
+                    //濡傛灉琛ㄦ牸绗琲琛岀殑绗竴鍒椾负绌猴紝鍒欏垽鏂负杩欎竴琛岀殑鏁版嵁涓虹┖锛岃烦鍑哄惊鐜苟涓斾笉鎶婃暟鎹啓鍏� tb2
+                    if (ExcelDs.Tables[0].Rows[i][0].ToString() == "" && ExcelDs.Tables[0].Rows[i][1].ToString() == "")
+                    {
+                        continue;
+                    }                    
+                    //else if (oSystemParameter.omodel.JIT_DayPlan_TimeFrame != "0" && oSystemParameter.omodel.JIT_DayPlan_TimeFrame != "")
+                    //{
+                    //    Int32 HDays = Convert.ToInt32(oSystemParameter.omodel.JIT_DayPlan_TimeFrame) * 7;
+
+
+
+
+                    //    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
+                    //    {
+                    //        if (Convert.ToInt32(ExcelDs.Tables[0].Rows[i][j].ToString()) > 0 )
+                    //        {
+                    //            continue;
+                    //        }                          
+                    //    }                       
+                    //}
+                    else
+                    {
+                        tb2.Rows.Add(row);
+                    }
+                }
+
+                var error = "";
+                var ErrorResult = "";
+
+                //鏌ヨ鐢熶骇璁㈠崟琛ㄥ垽鏂湁娌℃湁鐢熶骇璁㈠崟淇℃伅
+                for (int i = 0; i < tb2.Rows.Count; i++)
+                {
+                    if (tb2.Rows[i]["缁勭粐缂栫爜*"].ToString() == "")
+                        error += "缁勭粐缂栫爜涓嶈兘涓虹┖;";
+                    if (tb2.Rows[i]["鐢熶骇璁㈠崟鍙�*"].ToString() == "")
+                        error += "鐢熶骇璁㈠崟鍙蜂笉鑳戒负绌�;\n";
+                    if (tb2.Rows[i]["鐢熶骇璁㈠崟鏄庣粏琛屽彿*"].ToString() == "")
+                        error += "鐢熶骇璁㈠崟鏄庣粏琛屽彿涓嶈兘涓虹┖;";
+                    if (tb2.Rows[i]["鐢熶骇杞﹂棿缂栫爜*"].ToString() == "")
+                        error += "鐢熶骇杞﹂棿缂栫爜涓嶈兘涓虹┖;";
+                    if (tb2.Rows[i]["鐢熶骇璧勬簮缂栫爜*"].ToString() == "")
+                        error += "鐢熶骇璧勬簮缂栫爜涓嶈兘涓虹┖;";
+                    if (tb2.Rows[i]["鐗╂枡缂栫爜*"].ToString() == "")
+                        error += "鐗╂枡缂栫爜涓嶈兘涓虹┖;";
+
+                    if (error.Length > 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = ErrorResult += $"Excel妯℃澘瀛樺湪閿欒锛岃鏁皗i + 1}:{error}\r\n"; ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    string sql1 = string.Format("select * from h_v_JIT_ICMOBillList_DR where 鍗曟嵁鍙�='{0}' and 鐢熶骇杞﹂棿浠g爜='{1}' and 浜у搧浠g爜='{2}' and 鏄庣粏琛屽彿={3} ",
+                        tb2.Rows[i]["鐢熶骇璁㈠崟鍙�*"].ToString(), tb2.Rows[i]["鐢熶骇杞﹂棿缂栫爜*"].ToString(), tb2.Rows[i]["鐗╂枡缂栫爜*"].ToString(), tb2.Rows[i]["鐢熶骇璁㈠崟鏄庣粏琛屽彿*"].ToString());
+                    ds = oCN.RunProcReturn(sql1, "h_v_JIT_ICMOBillList_DR");
+
+                    if (ds.Tables[0].Rows.Count == 0)
+                    {
+                        error += $"娌℃湁鐢熶骇璁㈠崟淇℃伅锛岀敓浜ц鍗曞彿:{ tb2.Rows[i]["鐢熶骇璁㈠崟鍙�*"].ToString()},鐢熶骇杞﹂棿缂栫爜:{tb2.Rows[i]["鐢熶骇杞﹂棿缂栫爜*"].ToString()}" +
+                               $",鐢熶骇璁㈠崟鏄庣粏琛屽彿:{ tb2.Rows[i]["鐢熶骇璁㈠崟鏄庣粏琛屽彿*"].ToString()},鐗╂枡缂栫爜:{ tb2.Rows[i]["鐗╂枡缂栫爜*"].ToString()}";
+                    }
+
+                    if (error.Length > 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = ErrorResult += $"Excel妯℃澘瀛樺湪閿欒锛岃鏁皗i + 1}:{error}\r\n"; ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        tb2.Rows[i]["HMaterID"] = ds.Tables[0].Rows[0]["HMaterID"].ToString();
+                        tb2.Rows[i]["鐗╂枡鍚嶇О"] = ds.Tables[0].Rows[0]["浜у搧鍚嶇О"].ToString();
+                        tb2.Rows[i]["瑙勬牸鍨嬪彿"] = ds.Tables[0].Rows[0]["瑙勬牸鍨嬪彿"].ToString();
+                        tb2.Rows[i]["HWorkShopID"] = ds.Tables[0].Rows[0]["HDeptID"].ToString();
+                        tb2.Rows[i]["ICMOBillHInterID"] = ds.Tables[0].Rows[0]["hmainid"].ToString();//鐢熶骇璁㈠崟涓籭d
+                        tb2.Rows[i]["ICMOBillHEntryID"] = ds.Tables[0].Rows[0]["HEntryID"].ToString();//鐢熶骇璁㈠崟瀛恑d
+                        string sErr = "";
+                        if (oSystemParameter.ShowBill(ref sErr))
+                        {
+                            if (oSystemParameter.omodel.WMS_CampanyName != "瀹濆伐")
+                            {
+                                tb2.Rows[i]["鐢熶骇璁㈠崟鏁伴噺"] = ds.Tables[0].Rows[0]["鐢熶骇浠诲姟鍗曟暟閲�"].ToString();//鐢熶骇璁㈠崟鏁伴噺
+                            }
+                        }
+                        //tb2.Rows[i]["鐢熶骇璁㈠崟鏁伴噺"] = ds.Tables[0].Rows[0]["鐢熶骇浠诲姟鍗曟暟閲�"].ToString();//鐢熶骇璁㈠崟鏁伴噺
+                        tb2.Rows[i]["HSeOrderBillNo"] = ds.Tables[0].Rows[0]["閿�鍞鍗曞彿"].ToString();//閿�鍞鍗曞彿
+                    }
+
+                    ds = oCN.RunProcReturn("select * from h_v_JIT_WorkBillSortBillList_DR " +
+                        $"where  鐢熶骇璁㈠崟鍙�='{tb2.Rows[i]["鐢熶骇璁㈠崟鍙�*"].ToString()}'  and 鐢熶骇璁㈠崟鏄庣粏琛屽彿='{tb2.Rows[i]["鐢熶骇璁㈠崟鏄庣粏琛屽彿*"].ToString()}' " +
+                        $"and 鐢熶骇杞﹂棿缂栫爜='{tb2.Rows[i]["鐢熶骇杞﹂棿缂栫爜*"].ToString()}' and 鐗╂枡浠g爜='{tb2.Rows[i]["鐗╂枡缂栫爜*"].ToString()}' " +
+                        $"and 鐢熶骇璧勬簮缂栫爜='{tb2.Rows[i]["鐢熶骇璧勬簮缂栫爜*"].ToString()}' ", "h_v_JIT_WorkBillSortBillList_DR");
+                    //缁勭粐缂栫爜='{tb2.Rows[i]["缁勭粐缂栫爜*"].ToString()}' and
+                    //and 鐢熶骇璧勬簮缂栫爜='{tb2.Rows[i]["鐢熶骇璧勬簮缂栫爜*"].ToString()}'
+
+                    if (ds.Tables[0].Rows.Count > 0)
+                    {
+                        tb2.Rows[i]["hmainid"] = ds.Tables[0].Rows[0]["hmainid"].ToString();
+                        tb2.Rows[i]["鍗曟嵁鍙�"] = ds.Tables[0].Rows[0]["鍗曟嵁鍙�"].ToString();
+                        if (oSystemParameter.omodel.WMS_CampanyName != "瀹濆伐")
+                        {
+                            tb2.Rows[i]["浼樺厛绾�"] = ds.Tables[0].Rows[0]["浼樺厛绾�"].ToString();
+                        }
+                        tb2.Rows[i]["HSourceID"] = ds.Tables[0].Rows[0]["HSourceID"].ToString();
+                        tb2.Rows[i]["HEmpID"] = ds.Tables[0].Rows[0]["HEmpID"].ToString();
+                        tb2.Rows[i]["鍛樺伐缂栫爜"] = ds.Tables[0].Rows[0]["鑱屽憳浠g爜"].ToString();
+                        tb2.Rows[i]["鍛樺伐"] = ds.Tables[0].Rows[0]["鑱屽憳"].ToString();
+                        tb2.Rows[i]["HUnitID"] = ds.Tables[0].Rows[0]["HUnitID"].ToString();
+                        tb2.Rows[i]["璁¢噺鍗曚綅"] = ds.Tables[0].Rows[0]["璁¢噺鍗曚綅"].ToString();
+                        tb2.Rows[i]["鎵规鍙�"] = ds.Tables[0].Rows[0]["鎵规"].ToString();
+                        tb2.Rows[i]["閿�鍞鍗曟暟閲�"] = ds.Tables[0].Rows[0]["閿�鍞鍗曟暟閲�"].ToString();
+                        tb2.Rows[i]["鎬婚綈濂楁暟閲�"] = ds.Tables[0].Rows[0]["榻愬鏁伴噺"].ToString();
+                    }
+                    else
+                    {
+                        //鍛樺伐
+                        ds = oCN.RunProcReturn($"select * from Gy_Employee with(nolock) where HNumber='{tb2.Rows[i]["鍛樺伐缂栫爜"].ToString()}'", "Gy_Employee");
+                        if (ds.Tables[0].Rows.Count > 0) {
+                            tb2.Rows[i]["HEmpID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                            tb2.Rows[i]["鍛樺伐"] = ds.Tables[0].Rows[0]["HName"].ToString();
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = $"绗瑊i + 1}琛�,鍛樺伐鏌ユ棤鏁版嵁!";
+                            objJsonResult.data = tb2;
+                            return objJsonResult;
+                        }
+
+                        //璁¢噺鍗曚綅
+                        ds = oCN.RunProcReturn($"select * from Gy_Unit with(nolock) where HNumber='{tb2.Rows[i]["璁¢噺鍗曚綅"].ToString()}'", "Gy_Unit");
+                        if (ds.Tables[0].Rows.Count > 0)
+                        {
+                            tb2.Rows[i]["HUnitID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = $"绗瑊i + 1}琛�,璁¢噺鍗曚綅鏌ユ棤鏁版嵁!";
+                            objJsonResult.data = tb2;
+                            return objJsonResult;
+                        }
+
+                        //鐢熶骇璧勬簮
+                        ds = oCN.RunProcReturn($"select * from Gy_Source with(nolock) where HNumber='{tb2.Rows[i]["鐢熶骇璧勬簮缂栫爜*"].ToString()}'", "Gy_Source");
+                        if (ds.Tables[0].Rows.Count > 0)
+                        {
+                            tb2.Rows[i]["HSourceID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                        }
+                        else {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = $"绗瑊i+1}琛�,鐢熶骇璧勬簮鏌ユ棤鏁版嵁!";
+                            objJsonResult.data = tb2;
+                            return objJsonResult;
+                        }
+                    }
+                    //缁勭粐
+                    ds = oCN.RunProcReturn($"select * from Xt_ORGANIZATIONS with(nolock) where HNumber='{tb2.Rows[i]["缁勭粐缂栫爜*"].ToString()}'", "Xt_ORGANIZATIONS");
+                    if (ds.Tables[0].Rows.Count > 0)
+                    {
+                        tb2.Rows[i]["HProdORGID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = $"绗瑊i + 1}琛�,缁勭粐鏌ユ棤鏁版嵁!";
+                        objJsonResult.data = tb2;
+                        return objJsonResult;
+                    }
                 }
 
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
-                objJsonResult.Message = "Sucess锛�";
-                objJsonResult.data = ds.Tables[0];
+                objJsonResult.Message = ErrorResult;
+                objJsonResult.data = tb2;
                 return objJsonResult;
             }
             catch (Exception e)
@@ -45,5 +273,916 @@
             }
         }
         #endregion
+
+        #region 鐢熶骇鏃ヨ鍒� 瀵煎叆(淇濆瓨)
+        [Route("JIT_DayPlanPlatFormImport/JIT_DayPlanPlatFormImport_btnSave")]
+        [HttpPost]
+        public object JIT_DayPlanPlatFormImport_btnSave([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            oCN.BeginTran();
+            //淇濆瓨涓昏〃
+            objJsonResult = AddBillMain(msg1);
+            if (objJsonResult.code == "0")
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = objJsonResult.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            oCN.Commit();
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = "鍗曟嵁淇濆瓨鎴愬姛锛�";
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+
+        public json AddBillMain(string msg1)
+        {
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string msg3 = sArray[1].ToString();
+            string user = sArray[2].ToString();
+
+            try
+            {
+                if (!DBUtility.ClsPub.Security_Log("Sc_WorkBillSortBill_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //琛ㄥご瀛楁
+                omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<Sc_WorkBillSortBillMain>(msg2);
+
+                //JSON搴忓垪鍖栬浆鎹㈠瓧鍏搁泦鍚�
+                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+                List<object> jb = JsonConvert.DeserializeObject<List<object>>(msg3);
+                foreach (JObject item in jb)
+                {
+                    Dictionary<string, string> dic = new Dictionary<string, string>();
+                    foreach (var itm in item.Properties())
+                    {
+                        dic.Add(itm.Name, itm.Value.ToString());
+                    }
+                    list.Add(dic);
+                }
+
+              
+                
+
+                for (int i = 0; i < list.Count; i++)
+                {
+                    int TrueCount = 0, SumCount = 0;
+                    long HInterID = 0;
+                    var HBillNo = "";
+                    if (list[i]["鍗曟嵁鍙�"].ToString() == "" && list[i]["hmainid"].ToString() == "")
+                    {
+                        HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);//鑾峰緱涓�涓柊鐨勫崟鎹彿
+                        HInterID = DBUtility.ClsPub.CreateBillID_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo);//鑾峰緱涓�涓柊鐨刬d
+                        var HICMOBillNo = list[i]["鐢熶骇璁㈠崟鍙�*"].ToString();
+                        var HICMOEntrySEQ = list[i]["鐢熶骇璁㈠崟鏄庣粏琛屽彿*"].ToString();
+                        var HProdORGID = list[i]["HProdORGID"].ToString();
+                        var HWorkShopID = list[i]["HWorkShopID"].ToString();
+                        var HSourceID = list[i]["HSourceID"].ToString();
+                        var HWorkQty = DBUtility.ClsPub.isDoule(list[i]["浜ц兘"]);
+                        var HYX = list[i]["浼樺厛绾�"].ToString();
+                        var HEmpID = list[i]["HEmpID"].ToString();
+                        var HMaterID = list[i]["HMaterID"].ToString();
+                        var HMaterName = list[i]["鐗╂枡鍚嶇О"].ToString();
+                        var HMaterModel = list[i]["瑙勬牸鍨嬪彿"].ToString();
+                        var HUnitID = list[i]["HUnitID"].ToString();
+                        var HBatchNo = list[i]["鎵规鍙�"].ToString();
+                        var HSeOrderBillQty = list[i]["閿�鍞鍗曟暟閲�"].ToString();
+                        var HPlanQty = list[i]["鐢熶骇璁㈠崟鏁伴噺"].ToString();
+                        var HCompleteQty = list[i]["鎬婚綈濂楁暟閲�"].ToString();
+                        var HOrderType = omdelMian.HOrderType;
+                        var HDate = omdelMian.HDate;
+                        var HMainSourceInterID = list[i]["ICMOBillHInterID"].ToString();
+                        var HMainSourceEntryID = list[i]["ICMOBillHEntryID"].ToString();
+                        var HSeOrderBillNo = list[i]["HSeOrderBillNo"].ToString();
+
+                        string sql = $"select * from  Sc_WorkBillSortBillMain where HMainSourceInterID={HMainSourceInterID}" +
+                          $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID} and ISNULL(HDeleteMan,'') = ''";
+                        LogService.Write("sql:" + sql);
+                        ds = oCN.RunProcReturn(sql, "Sc_WorkBillSortBillMain");
+                        if (ds.Tables[0].Rows.Count > 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = $"绗瑊i + 1}琛岀敓浜ц祫婧愭湁閲嶅,璇蜂慨鏀�!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+
+                        //涓昏〃
+                        oCN.RunProc("insert into Sc_WorkBillSortBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType," +
+                            "HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HICMOBillNo,HOrderType," +
+                            "HICMOEntrySEQ,HWorkShopID,HSourceID, HYX,HWorkQty, HEmpID," +
+                            " HMaterID, HMaterName, HMaterModel, HUnitID, HBatchNo," +
+                            " HSeOrderBillQty, HPlanQty, HCompleteQty,HPreparatDate," +
+                            "HMainSourceInterID,HMainSourceEntryID,HICMOInterID,HICMOEntryID,HProdORGID,HICMOInterID_Sec,HICMOEntryID_Sec" +
+                            ",HSeOrderBillNo)values" +
+                            $"({HInterID},'{HBillNo}',{DateTime.Now.Year},{DateTime.Now.Month},'{BillType}'," +
+                            $"'{BillType}',GETDATE(),1,'{user}','{HDate}','{HICMOBillNo}','{HOrderType}'," +
+                            $"{(HICMOEntrySEQ == "" ? 0.ToString() : HICMOEntrySEQ)},{(HWorkShopID == "" ? 0.ToString() : HWorkShopID)},{(HSourceID == "" ? 0.ToString() : HSourceID)}, {(HYX == "" ? 0.ToString() : HYX)},{(HWorkQty)}, {(HEmpID == "" ? 0.ToString() : HEmpID)}," +
+                            $" {(HMaterID == "" ? 0.ToString() : HMaterID)}, '{HMaterName}', '{HMaterModel}', {(HUnitID == "" ? 0.ToString() : HUnitID)}, '{HBatchNo}'," +
+                            $" {(HSeOrderBillQty == "" ? 0.ToString() : HSeOrderBillQty)}, {(HPlanQty == "" ? 0.ToString() : HPlanQty)}, {(HCompleteQty == "" ? 0.ToString() : HCompleteQty)},getdate()," +
+                            $" {HMainSourceInterID},{HMainSourceEntryID},{HMainSourceInterID},{HMainSourceEntryID},{HProdORGID}, {HMainSourceInterID},{HMainSourceEntryID}" +
+                            $",'{HSeOrderBillNo}')");
+                    }
+
+                    int SumDay = 31; //鍔ㄦ�佷袱鏈堜箣宸� 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;
+
+
+                    for (int j = 0; j < SumDay; j++)
+                    {
+                        LogService.Write("1:" + list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString());
+                        LogService.Write("2:" + DateTime.Now.AddDays(j).ToString("yyyy-MM-dd"));
+                        //涓昏〃瀛愯〃閮芥湁鏁版嵁
+                        if (list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString() != "")
+                        {
+                            SumCount += 1;
+                            ////淇濆瓨瀛愯〃
+                            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()));
+
+                            if (objJsonResult.count == 1)
+                            {
+                                TrueCount += 1;
+                            }
+                        }
+                        //涓昏〃鏈夋暟鎹� 瀛愯〃鏃犳暟鎹�
+                        if (j == SumDay - 1 && SumCount == 0 && HInterID != 0 && HBillNo != "")
+                        {
+                            objJsonResult = AddBillSub(HInterID.ToString(), HBillNo, DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd").ToString()), 0);
+                        }
+                    }
+                    if (TrueCount != SumCount)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = objJsonResult.Message;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+               
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = null;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        public json AddBillSub(string HInterID,string HBillNo, DateTime date, int HQTY)
+        {
+            //鑾峰彇琛ㄦ牸鏁版嵁
+            ds = oCN.RunProcReturn($"select * from  h_v_JIT_Sc_WorkBillSortBillList where 鍗曟嵁鍙�='{HBillNo}'", "h_v_JIT_Sc_WorkBillSortBillList");
+            int count = 0;
+            if (ds.Tables[0].Rows.Count > 0)
+            {
+                //鍒ゆ柇瀛愯〃鏄惁鏈夊綋鏃ョ殑鏃ユ湡浠ュ強鏃ユ湡鎵�瀵瑰簲鐨勬暟閲�
+                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}" +
+                            $"  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)" +
+                            $"values({HInterID}, {(ds.Tables[0].Rows.Count + 1)}," +
+                            $" '{date}', {HQTY})");
+            }
+
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = null;
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+        #endregion
+
+        #region 鐢熶骇鏃ヨ鍒掍氦鏈�(涓夊崌瀵煎叆) 鏂囦欢涓婁紶
+        [Route("JIT_DayPlanPlatFormImport/JIT_DayPlanPlatFormImport_SS")]
+        [HttpPost]
+        public object JIT_DayPlanPlatFormImport_SS()
+        {
+            try
+            {
+                //鑾峰彇鏂囦欢鍚嶇О
+                var file = HttpContext.Current.Request.Files[0];
+                //鑾峰彇鏂囦欢鐗╃悊璺緞
+                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
+                //淇濆瓨鏂囦欢
+                file.SaveAs(ExcelPath);
+
+                NpoiHelper np = new NpoiHelper();
+                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
+
+                //鍒犻櫎鏂囦欢
+                File.Delete(ExcelPath);
+
+                //鍒涘缓涓存椂琛�
+                DataTable tb2 = new DataTable("dt2");
+
+                //娣诲姞鍒楀悕
+                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
+                {
+                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
+                }
+                //妯℃澘缂哄皯鍒� 浣嗛渶瑕佷粠鏁版嵁搴撲腑鏌ヨ鍑烘潵鏄剧ず鍦ㄩ〉闈㈢殑瀛楁
+                tb2.Columns.Add("hmainid", typeof(Int32));
+                tb2.Columns.Add("HMaterID", typeof(Int32));
+                tb2.Columns.Add("ICMOBillHInterID", typeof(Int32));
+                tb2.Columns.Add("ICMOBillHEntryID", typeof(Int32));
+                //鑾峰彇绯荤粺鍙傛暟
+                string Ret = "";
+                oSystemParameter.ShowBill(ref Ret);
+
+                LogService.Write("excel鍊硷細" + ExcelDs.Tables[0].Rows[1][1].ToString());//2024-11-26
+                //娣诲姞鏁版嵁
+                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
+                {
+                    DataRow row = tb2.NewRow();
+                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
+                    {
+                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
+                    }
+                    //濡傛灉琛ㄦ牸绗琲琛岀殑绗竴鍒椾负绌猴紝鍒欏垽鏂负杩欎竴琛岀殑鏁版嵁涓虹┖锛岃烦鍑哄惊鐜苟涓斾笉鎶婃暟鎹啓鍏� tb2
+                    if (ExcelDs.Tables[0].Rows[i][0].ToString() == "" && ExcelDs.Tables[0].Rows[i][1].ToString() == "")
+                    {
+                        continue;
+                    }
+                   
+                    else
+                    {
+                        tb2.Rows.Add(row);
+                    }
+                }
+
+                var error = "";
+                var ErrorResult = "";
+
+                //鏌ヨ鐢熶骇璁㈠崟琛ㄥ垽鏂湁娌℃湁鐢熶骇璁㈠崟淇℃伅
+                for (int i = 0; i < tb2.Rows.Count; i++)
+                {
+                    //if (tb2.Rows[i]["璁″垝缁撴潫鏃ユ湡"].ToString() == "")
+                    //    error += "璁″垝缁撴潫鏃ユ湡涓嶈兘涓虹┖;";
+                    if (tb2.Rows[i]["瀹㈡埛璁㈠崟鍙�"].ToString() == "")
+                        error += "瀹㈡埛璁㈠崟鍙蜂笉鑳戒负绌�;";
+                    if (tb2.Rows[i]["鐗╂枡缂栫爜"].ToString() == "")
+                        error += "鐗╂枡缂栫爜涓嶈兘涓虹┖;";
+
+                    if (error.Length > 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = ErrorResult += $"Excel妯℃澘瀛樺湪閿欒锛岃鏁皗i + 1}:{error}\r\n"; ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //鏌ユ壘鏄惁瀛樺湪瀵瑰簲鐢熶骇璁㈠崟
+                    string sql1 = string.Format("select * from h_v_IF_ICMOBillList where 瀹㈡埛璁㈠崟鍙�='{0}' and 浜у搧浠g爜='{1}' and 鐘舵�� in ('璁″垝纭','寮�宸�')",
+                        tb2.Rows[i]["瀹㈡埛璁㈠崟鍙�"].ToString(), tb2.Rows[i]["鐗╂枡缂栫爜"].ToString());
+                    ds = oCN.RunProcReturn(sql1, "h_v_IF_ICMOBillList");
+
+                    if (ds.Tables[0].Rows.Count == 0)
+                    {
+                        error += $"娌℃湁绗﹀悎鏉′欢寰楃敓浜ц鍗曚俊鎭紝瀹㈡埛璁㈠崟鍙�:{ tb2.Rows[i]["瀹㈡埛璁㈠崟鍙�"].ToString()},浜у搧浠g爜:{tb2.Rows[i]["鐗╂枡缂栫爜"].ToString()}";
+                    }
+
+                    if (error.Length > 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = ErrorResult += $"Excel妯℃澘瀛樺湪閿欒锛岃鏁皗i + 1}:{error}\r\n"; ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        tb2.Rows[i]["HMaterID"] = ds.Tables[0].Rows[0]["HMaterID"].ToString();
+                        tb2.Rows[i]["ICMOBillHInterID"] = ds.Tables[0].Rows[0]["hmainid"].ToString();//鐢熶骇璁㈠崟涓籭d
+                        tb2.Rows[i]["ICMOBillHEntryID"] = ds.Tables[0].Rows[0]["HEntryID"].ToString();//鐢熶骇璁㈠崟瀛恑d
+                    }
+                    //鏌ユ壘鏄惁瀛樺湪瀵瑰簲鏃ヨ鍒掑伐鍗�
+                    var dt = oCN.RunProcReturn($"select * from  h_v_JIT_Sc_WorkBillSortBillList_Left where 婧愬崟涓诲唴鐮� in({ds.Tables[0].Rows[0]["hmainid"].ToString()}) and  婧愬崟瀛愬唴鐮� in({ds.Tables[0].Rows[0]["HEntryID"].ToString()})", "h_v_JIT_Sc_WorkBillSortBillList");
+                    if (dt.Tables[0].Rows.Count > 0)
+                    {
+                        tb2.Rows[i]["hmainid"] = dt.Tables[0].Rows[0]["hmainid"].ToString();
+                    }
+
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = ErrorResult;
+                objJsonResult.data = tb2;
+                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_DayPlanPlatFormImport/JIT_DayPlanPlatFormImport_btnSave_SS")]
+        [HttpPost]
+        public object JIT_DayPlanPlatFormImport_btnSave_SS([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            oCN.BeginTran();
+            //淇濆瓨涓昏〃
+            objJsonResult = AddBillMain_SS(msg1);
+            if (objJsonResult.code == "0")
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = objJsonResult.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            oCN.Commit();
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = "鍗曟嵁淇濆瓨鎴愬姛锛�";
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+
+        public json AddBillMain_SS(string msg1)
+        {
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string msg3 = sArray[1].ToString();
+            string user = sArray[2].ToString();
+
+            try
+            {
+                if (!DBUtility.ClsPub.Security_Log("Sc_WorkBillSortBill_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //琛ㄥご瀛楁
+                omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<Sc_WorkBillSortBillMain>(msg2);
+
+                //JSON搴忓垪鍖栬浆鎹㈠瓧鍏搁泦鍚�
+                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+                List<object> jb = JsonConvert.DeserializeObject<List<object>>(msg3);
+                foreach (JObject item in jb)
+                {
+                    Dictionary<string, string> dic = new Dictionary<string, string>();
+                    foreach (var itm in item.Properties())
+                    {
+                        dic.Add(itm.Name, itm.Value.ToString());
+                    }
+                    list.Add(dic);
+                }
+
+
+
+
+                for (int i = 0; i < list.Count; i++)
+                {
+                    long HInterID = 0;
+                    var HBillNo = "";
+                    if (list[i]["hmainid"].ToString() == "")
+                    {
+                        HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);//鑾峰緱涓�涓柊鐨勫崟鎹彿
+                        HInterID = DBUtility.ClsPub.CreateBillID_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo);//鑾峰緱涓�涓柊鐨刬d
+                        var HMainSourceInterID = list[i]["ICMOBillHInterID"].ToString();
+                        var HMainSourceEntryID = list[i]["ICMOBillHEntryID"].ToString();
+                        var HPlanEndDate = list[i]["璁″垝缁撴潫鏃ユ湡"].ToString();
+                        //鑾峰彇瀵瑰簲璁㈠崟淇℃伅
+                        ds = oCN.RunProcReturn($"exec h_p_ICMOBillList_PrimarySubTable '{HMainSourceInterID}','{HMainSourceEntryID}'", "h_p_ICMOBillList_PrimarySubTable");
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = $"娌℃壘鍒板搴旂鍚堟潯浠跺緱璁㈠崟淇℃伅锛岃鏁皗i + 1}\r\n"; ;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        var HICMOBillNo = ds.Tables[0].Rows[0]["鐢熶骇璁㈠崟鍙�"].ToString();
+                        var HICMOEntrySEQ = ds.Tables[0].Rows[0]["鐢熶骇璁㈠崟鏄庣粏琛屽彿"].ToString();
+                        var HProdORGID = ds.Tables[0].Rows[0]["HProdORGID"].ToString();
+                        var HWorkShopID = ds.Tables[0].Rows[0]["HWorkShopID"].ToString();
+                        var HSourceID = ds.Tables[0].Rows[0]["HSourceID"].ToString();
+                        var HWorkQty = DBUtility.ClsPub.isDoule(ds.Tables[0].Rows[0]["灏忔椂浜ц兘"].ToString());
+                        var HYX = ds.Tables[0].Rows[0]["浼樺厛绾�"].ToString();
+                        var HEmpID = ds.Tables[0].Rows[0]["鎿嶄綔宸�"].ToString();
+                        var HMaterID = ds.Tables[0].Rows[0]["HMaterID"].ToString();
+                        var HMaterName = ds.Tables[0].Rows[0]["鐗╂枡鍚嶇О"].ToString();
+                        var HMaterModel = ds.Tables[0].Rows[0]["瑙勬牸鍨嬪彿"].ToString();
+                        var HUnitID = ds.Tables[0].Rows[0]["HUnitID"].ToString();
+                        var HBatchNo = "";//鎵规鍙�
+                        var HSeOrderBillQty = ds.Tables[0].Rows[0]["閿�鍞鍗曟暟閲�"].ToString();
+                        var HPlanQty = ds.Tables[0].Rows[0]["璁″垝鏁伴噺"].ToString();
+                        var HCompleteQty = "";//鎬婚綈濂楁暟閲�
+                        var HOrderType = omdelMian.HOrderType;
+                        var HDate = omdelMian.HDate;
+                        var HSeOrderBillNo = ds.Tables[0].Rows[0]["閿�鍞鍗曞彿"].ToString();
+                        //涓昏〃
+                        oCN.RunProc("insert into Sc_WorkBillSortBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType," +
+                            "HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HICMOBillNo,HOrderType," +
+                            "HICMOEntrySEQ,HWorkShopID,HSourceID, HYX,HWorkQty, HEmpID," +
+                            " HMaterID, HMaterName, HMaterModel, HUnitID, HBatchNo," +
+                            " HSeOrderBillQty, HPlanQty, HCompleteQty,HPreparatDate," +
+                            "HMainSourceInterID,HMainSourceEntryID,HICMOInterID,HICMOEntryID,HProdORGID,HICMOInterID_Sec,HICMOEntryID_Sec" +
+                            ",HSeOrderBillNo,HPlanEndDate)values" +
+                            $"({HInterID},'{HBillNo}',{DateTime.Now.Year},{DateTime.Now.Month},'{BillType}'," +
+                            $"'{BillType}',GETDATE(),1,'{user}','{HDate}','{HICMOBillNo}','{HOrderType}'," +
+                            $"{(HICMOEntrySEQ == "" ? 0.ToString() : HICMOEntrySEQ)},{(HWorkShopID == "" ? 0.ToString() : HWorkShopID)},{(HSourceID == "" ? 0.ToString() : HSourceID)}, {(HYX == "" ? 0.ToString() : HYX)},{(HWorkQty)}, {(HEmpID == "" ? 0.ToString() : HEmpID)}," +
+                            $" {(HMaterID == "" ? 0.ToString() : HMaterID)}, '{HMaterName}', '{HMaterModel}', {(HUnitID == "" ? 0.ToString() : HUnitID)}, '{HBatchNo}'," +
+                            $" {(HSeOrderBillQty == "" ? 0.ToString() : HSeOrderBillQty)}, {(HPlanQty == "" ? 0.ToString() : HPlanQty)}, {(HCompleteQty == "" ? 0.ToString() : HCompleteQty)},getdate()," +
+                            $" {HMainSourceInterID},{HMainSourceEntryID},{HMainSourceInterID},{HMainSourceEntryID},{HProdORGID}, {HMainSourceInterID},{HMainSourceEntryID}" +
+                            $",'{HSeOrderBillNo}','{HPlanEndDate}')");
+                        //鎻掑叆瀛愯〃鏁版嵁
+                        objJsonResult = AddBillSub(HInterID.ToString(), HBillNo, DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd").ToString()), 0);
+                    }//濡傛灉宸插瓨鍦ㄦ棩璁″垝宸ュ崟鏇存柊瀵瑰簲璁″垝缁撴潫鏃ユ湡
+                    else
+                    {
+                        var hmainid = list[i]["hmainid"].ToString();
+                        var HPlanEndDate = list[i]["璁″垝缁撴潫鏃ユ湡"].ToString();
+                        //鏇存柊浜ゆ湡
+                        if (HPlanEndDate != "" )
+                        {
+                            oCN.RunProc($"update Sc_WorkBillSortBillMain set HPlanEndDate = '{HPlanEndDate}' where HInterID ={hmainid}");
+                        }
+                    }
+
+                }
+
+
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = null;
+                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_DayPlanPlatFormImport/JIT_DayPlanPlatFormImport_SS_Sec")]
+        [HttpPost]
+        public object JIT_DayPlanPlatFormImport_SS_Sec()
+        {
+            try
+            {
+                //鑾峰彇鏂囦欢鍚嶇О
+                var file = HttpContext.Current.Request.Files[0];
+                //鑾峰彇鏂囦欢鐗╃悊璺緞
+                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
+                //淇濆瓨鏂囦欢
+                file.SaveAs(ExcelPath);
+
+                NpoiHelper np = new NpoiHelper();
+                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
+
+                //鍒犻櫎鏂囦欢
+                File.Delete(ExcelPath);
+
+                //鍒涘缓涓存椂琛�
+                DataTable tb2 = new DataTable("dt2");
+
+                //娣诲姞鍒楀悕
+                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
+                {
+                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
+                }
+                //妯℃澘缂哄皯鍒� 浣嗛渶瑕佷粠鏁版嵁搴撲腑鏌ヨ鍑烘潵鏄剧ず鍦ㄩ〉闈㈢殑瀛楁
+                tb2.Columns.Add("hmainid", typeof(Int32));//璁″垝鍗昳d
+                tb2.Columns.Add("HMaterID", typeof(Int32));
+                tb2.Columns.Add("HSourceID", typeof(Int32));//鐢熶骇璧勬簮
+                tb2.Columns.Add("ICMOBillHInterID", typeof(Int32));
+                tb2.Columns.Add("ICMOBillHEntryID", typeof(Int32));
+                //鑾峰彇绯荤粺鍙傛暟
+                string Ret = "";
+                oSystemParameter.ShowBill(ref Ret);
+
+                LogService.Write("excel鍊硷細" + ExcelDs.Tables[0].Rows[1][5].ToString());//2024-11-26
+                //娣诲姞鏁版嵁
+                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
+                {
+                    DataRow row = tb2.NewRow();
+                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
+                    {
+                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
+                    }
+                    //濡傛灉琛ㄦ牸绗琲琛岀殑绗竴鍒椾负绌猴紝鍒欏垽鏂负杩欎竴琛岀殑鏁版嵁涓虹┖锛岃烦鍑哄惊鐜苟涓斾笉鎶婃暟鎹啓鍏� tb2
+                    if (ExcelDs.Tables[0].Rows[i][0].ToString() == "" && ExcelDs.Tables[0].Rows[i][1].ToString() == "")
+                    {
+                        continue;
+                    }
+
+                    else
+                    {
+                        tb2.Rows.Add(row);
+                    }
+                }
+
+                var error = "";
+                var ErrorResult = "";
+
+                //鏌ヨ鐢熶骇璁㈠崟琛ㄥ垽鏂湁娌℃湁鐢熶骇璁㈠崟淇℃伅
+                for (int i = 0; i < tb2.Rows.Count; i++)
+                {
+                    //if (tb2.Rows[i]["璁″垝缁撴潫鏃ユ湡"].ToString() == "")
+                    //    error += "璁″垝缁撴潫鏃ユ湡涓嶈兘涓虹┖;";
+                    if (tb2.Rows[i]["瀹㈡埛璁㈠崟鍙�"].ToString() == "")
+                        error += "瀹㈡埛璁㈠崟鍙蜂笉鑳戒负绌�;";
+                    if (tb2.Rows[i]["鐗╂枡缂栫爜"].ToString() == "")
+                        error += "鐗╂枡缂栫爜涓嶈兘涓虹┖;";
+
+                    if (error.Length > 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = ErrorResult += $"Excel妯℃澘瀛樺湪閿欒锛岃鏁皗i + 1}:{error}\r\n"; ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //璁剧疆瀵瑰簲鐢熶骇璧勬簮
+                    if (tb2.Rows[i]["鐢熶骇璧勬簮缂栫爜"].ToString() != "")
+                    {
+                        //鐢熶骇璧勬簮
+                        ds = oCN.RunProcReturn($"select * from Gy_Source with(nolock) where HNumber='{tb2.Rows[i]["鐢熶骇璧勬簮缂栫爜*"].ToString()}'", "Gy_Source");
+                        if (ds.Tables[0].Rows.Count > 0)
+                        {
+                            tb2.Rows[i]["HSourceID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = $"绗瑊i + 1}琛�,鐢熶骇璧勬簮鏌ユ棤鏁版嵁!";
+                            objJsonResult.data = tb2;
+                            return objJsonResult;
+                        }
+                    }
+
+                    //鏌ユ壘鏄惁瀛樺湪瀵瑰簲鐢熶骇璁㈠崟
+                    string sql1 = string.Format("select * from h_v_IF_ICMOBillList where 瀹㈡埛璁㈠崟鍙�='{0}' and 浜у搧浠g爜='{1}' and 鐘舵�� in ('璁″垝纭','寮�宸�')",
+                        tb2.Rows[i]["瀹㈡埛璁㈠崟鍙�"].ToString(), tb2.Rows[i]["鐗╂枡缂栫爜"].ToString());
+                    ds = oCN.RunProcReturn(sql1, "h_v_IF_ICMOBillList");
+
+                    if (ds.Tables[0].Rows.Count == 0)
+                    {
+                        error += $"娌℃湁绗﹀悎鏉′欢寰楃敓浜ц鍗曚俊鎭紝瀹㈡埛璁㈠崟鍙�:{ tb2.Rows[i]["瀹㈡埛璁㈠崟鍙�"].ToString()},浜у搧浠g爜:{tb2.Rows[i]["鐗╂枡缂栫爜"].ToString()}";
+                    }
+
+                    if (error.Length > 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = ErrorResult += $"Excel妯℃澘瀛樺湪閿欒锛岃鏁皗i + 1}:{error}\r\n"; ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        tb2.Rows[i]["HMaterID"] = ds.Tables[0].Rows[0]["HMaterID"].ToString();
+                        tb2.Rows[i]["ICMOBillHInterID"] = ds.Tables[0].Rows[0]["hmainid"].ToString();//鐢熶骇璁㈠崟涓籭d
+                        tb2.Rows[i]["ICMOBillHEntryID"] = ds.Tables[0].Rows[0]["HEntryID"].ToString();//鐢熶骇璁㈠崟瀛恑d
+                    }
+                    //鏌ユ壘鏄惁瀛樺湪瀵瑰簲鏃ヨ鍒掑伐鍗�
+                    var dt = oCN.RunProcReturn($"select * from  h_v_JIT_Sc_WorkBillSortBillList_Left where 婧愬崟涓诲唴鐮� in({ds.Tables[0].Rows[0]["hmainid"].ToString()}) and  婧愬崟瀛愬唴鐮� in({ds.Tables[0].Rows[0]["HEntryID"].ToString()})", "h_v_JIT_Sc_WorkBillSortBillList");
+                    if (dt.Tables[0].Rows.Count > 0)
+                    {
+                        tb2.Rows[i]["hmainid"] = dt.Tables[0].Rows[0]["hmainid"].ToString();
+                    }
+
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = ErrorResult;
+                objJsonResult.data = tb2;
+                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_DayPlanPlatFormImport/JIT_DayPlanPlatFormImport_btnSave_SS_Sec")]
+        [HttpPost]
+        public object JIT_DayPlanPlatFormImport_btnSave_SS_Sec([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            oCN.BeginTran();
+            //淇濆瓨涓昏〃
+            objJsonResult = AddBillMain_SS_Sec(msg1);
+            if (objJsonResult.code == "0")
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = objJsonResult.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            oCN.Commit();
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = "鍗曟嵁淇濆瓨鎴愬姛锛�";
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+
+        public json AddBillMain_SS_Sec(string msg1)
+        {
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string msg3 = sArray[1].ToString();
+            string user = sArray[2].ToString();
+
+            try
+            {
+                if (!DBUtility.ClsPub.Security_Log("Sc_WorkBillSortBill_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //琛ㄥご瀛楁
+                omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<Sc_WorkBillSortBillMain>(msg2);
+
+                //JSON搴忓垪鍖栬浆鎹㈠瓧鍏搁泦鍚�
+                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+                List<object> jb = JsonConvert.DeserializeObject<List<object>>(msg3);
+                foreach (JObject item in jb)
+                {
+                    Dictionary<string, string> dic = new Dictionary<string, string>();
+                    foreach (var itm in item.Properties())
+                    {
+                        dic.Add(itm.Name, itm.Value.ToString());
+                    }
+                    list.Add(dic);
+                }
+
+
+
+
+                for (int i = 0; i < list.Count; i++)
+                {
+                    int TrueCount = 0, SumCount = 0;//璁℃暟鍣ㄥ垽鏂瓙琛ㄥ鍏ユ暟閲忓拰瀹為檯鏁伴噺鏄惁鏈夊嚭鍏�
+                    long HInterID = 0;
+                    var HBillNo = "";
+                    if (list[i]["hmainid"].ToString() == "")
+                    {
+                        HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);//鑾峰緱涓�涓柊鐨勫崟鎹彿
+                        HInterID = DBUtility.ClsPub.CreateBillID_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo);//鑾峰緱涓�涓柊鐨刬d
+                        var HMainSourceInterID = list[i]["ICMOBillHInterID"].ToString();
+                        var HMainSourceEntryID = list[i]["ICMOBillHEntryID"].ToString();
+                        //鑾峰彇瀵瑰簲璁㈠崟淇℃伅
+                        ds = oCN.RunProcReturn($"exec h_p_ICMOBillList_PrimarySubTable '{HMainSourceInterID}','{HMainSourceEntryID}'", "h_p_ICMOBillList_PrimarySubTable");
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = $"娌℃壘鍒板搴旂鍚堟潯浠跺緱璁㈠崟淇℃伅锛岃鏁皗i + 1}\r\n"; ;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        var HICMOBillNo = ds.Tables[0].Rows[0]["鐢熶骇璁㈠崟鍙�"].ToString();
+                        var HICMOEntrySEQ = ds.Tables[0].Rows[0]["鐢熶骇璁㈠崟鏄庣粏琛屽彿"].ToString();
+                        var HProdORGID = ds.Tables[0].Rows[0]["HProdORGID"].ToString();
+                        var HWorkShopID = ds.Tables[0].Rows[0]["HWorkShopID"].ToString();
+                        var HSourceID = (list[i]["HSourceID"].ToString() != "0" && list[i]["HSourceID"].ToString() != "") ? list[i]["HSourceID"].ToString() : ds.Tables[0].Rows[0]["HSourceID"].ToString();//鐢熶骇璧勬簮
+                        var HWorkQty = DBUtility.ClsPub.isDoule((list[i]["灏忔椂浜ц兘"].ToString() != "0" && list[i]["灏忔椂浜ц兘"].ToString() != "") ? list[i]["灏忔椂浜ц兘"].ToString(): ds.Tables[0].Rows[0]["灏忔椂浜ц兘"].ToString());//灏忔椂浜ц兘
+                        var HYX = (list[i]["浼樺厛绾�"].ToString()!="0" && list[i]["浼樺厛绾�"].ToString() != "")? list[i]["浼樺厛绾�"].ToString():(i+1).ToString();//璁剧疆浼樺厛绾�
+                        var HEmpID = ds.Tables[0].Rows[0]["鎿嶄綔宸�"].ToString();
+                        var HMaterID = ds.Tables[0].Rows[0]["HMaterID"].ToString();
+                        var HMaterName = ds.Tables[0].Rows[0]["鐗╂枡鍚嶇О"].ToString();
+                        var HMaterModel = ds.Tables[0].Rows[0]["瑙勬牸鍨嬪彿"].ToString();
+                        var HUnitID = ds.Tables[0].Rows[0]["HUnitID"].ToString();
+                        var HBatchNo = "";//鎵规鍙�
+                        var HSeOrderBillQty = ds.Tables[0].Rows[0]["閿�鍞鍗曟暟閲�"].ToString();
+                        var HPlanQty = ds.Tables[0].Rows[0]["璁″垝鏁伴噺"].ToString();
+                        var HCompleteQty = "";//鎬婚綈濂楁暟閲�
+                        var HOrderType = omdelMian.HOrderType;
+                        var HDate = omdelMian.HDate;
+                        var HSeOrderBillNo = ds.Tables[0].Rows[0]["閿�鍞鍗曞彿"].ToString();
+                        var HPlanEndDate = list[i]["璁″垝缁撴潫鏃ユ湡"].ToString() != "" ? list[i]["璁″垝缁撴潫鏃ユ湡"].ToString():ds.Tables[0].Rows[0]["璁″垝缁撴潫鏃ユ湡"].ToString();
+                        var HLockOrder = 1;//閿佸畾宸ュ崟
+                        //涓昏〃
+                        oCN.RunProc("insert into Sc_WorkBillSortBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType," +
+                            "HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HICMOBillNo,HOrderType," +
+                            "HICMOEntrySEQ,HWorkShopID,HSourceID, HYX,HWorkQty, HEmpID," +
+                            " HMaterID, HMaterName, HMaterModel, HUnitID, HBatchNo," +
+                            " HSeOrderBillQty, HPlanQty, HCompleteQty,HPreparatDate," +
+                            "HMainSourceInterID,HMainSourceEntryID,HICMOInterID,HICMOEntryID,HProdORGID,HICMOInterID_Sec,HICMOEntryID_Sec" +
+                            ",HSeOrderBillNo,HPlanEndDate,HLockOrder)values" +
+                            $"({HInterID},'{HBillNo}',{DateTime.Now.Year},{DateTime.Now.Month},'{BillType}'," +
+                            $"'{BillType}',GETDATE(),1,'{user}','{HDate}','{HICMOBillNo}','{HOrderType}'," +
+                            $"{(HICMOEntrySEQ == "" ? 0.ToString() : HICMOEntrySEQ)},{(HWorkShopID == "" ? 0.ToString() : HWorkShopID)},{(HSourceID == "" ? 0.ToString() : HSourceID)}, {(HYX == "" ? 0.ToString() : HYX)},{(HWorkQty)}, {(HEmpID == "" ? 0.ToString() : HEmpID)}," +
+                            $" {(HMaterID == "" ? 0.ToString() : HMaterID)}, '{HMaterName}', '{HMaterModel}', {(HUnitID == "" ? 0.ToString() : HUnitID)}, '{HBatchNo}'," +
+                            $" {(HSeOrderBillQty == "" ? 0.ToString() : HSeOrderBillQty)}, {(HPlanQty == "" ? 0.ToString() : HPlanQty)}, {(HCompleteQty == "" ? 0.ToString() : HCompleteQty)},getdate()," +
+                            $" {HMainSourceInterID},{HMainSourceEntryID},{HMainSourceInterID},{HMainSourceEntryID},{HProdORGID}, {HMainSourceInterID},{HMainSourceEntryID}" +
+                            $",'{HSeOrderBillNo}','{HPlanEndDate}',{HLockOrder})");
+                    }//濡傛灉宸插瓨鍦ㄦ棩璁″垝宸ュ崟鏇存柊瀵瑰簲鐢熶骇璧勬簮灏忔椂浜ц兘
+                    else
+                    {
+                        var hmainid = list[i]["hmainid"].ToString();
+                        var HWorkQty = list[i]["灏忔椂浜ц兘"].ToString();
+                        var HSourceID = list[i]["HSourceID"].ToString();
+                        var HYX = list[i]["浼樺厛绾�"].ToString();
+                        var HPlanEndDate = list[i]["璁″垝缁撴潫鏃ユ湡"].ToString();
+                        //鏇存柊灏忔椂浜ц兘
+                        if (HWorkQty != ""&& HWorkQty != "0")
+                        {
+                            oCN.RunProc($"update Sc_WorkBillSortBillMain set HWorkQty = '{HWorkQty}' where HInterID ={hmainid}");
+                        }
+                        //鏇存柊鐢熶骇璧勬簮
+                        if (HSourceID != "" && HSourceID != "0")
+                        {
+                            oCN.RunProc($"update Sc_WorkBillSortBillMain set HSourceID = '{HSourceID}' where HInterID ={hmainid}");
+                        }
+                        //鏇存柊浼樺厛绾�
+                        if (HYX != "" && HYX != "0")
+                        {
+                            oCN.RunProc($"update Sc_WorkBillSortBillMain set HYX = '{HYX}' where HInterID ={hmainid}");
+                        }
+                        //鏇存柊璁″垝缁撴潫鏃ユ湡
+                        if (HPlanEndDate != "")
+                        {
+                            oCN.RunProc($"update Sc_WorkBillSortBillMain set HPlanEndDate = '{HPlanEndDate}' where HInterID ={hmainid}");
+                        }
+
+                    }
+                    int SumDay = 31; //鍔ㄦ�佷袱鏈堜箣宸� 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-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime date))
+                        {
+                            uniqueDates.Add(date);
+                        }
+                    }
+
+                    SumDay = uniqueDates.Count;
+
+                    //娣诲姞瀛愯〃
+                    for (int j = 0; j < SumDay; j++)
+                    {
+                        LogService.Write("1:" + list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString());
+                        LogService.Write("2:" + DateTime.Now.AddDays(j).ToString("yyyy-MM-dd"));
+                        //涓昏〃瀛愯〃閮芥湁鏁版嵁
+                        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;
+                            ////淇濆瓨瀛愯〃
+                            objJsonResult = AddBillSub_SS(HInterID == 0 ? list[i]["hmainid"].ToString() : HInterID.ToString()
+                                 , DateTime.Parse(DateTime.Now.AddDays(j).ToString("yyyy-MM-dd").ToString())
+                                 , int.Parse(list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString()));
+
+                            if (objJsonResult.count == 1)
+                            {
+                                TrueCount += 1;
+                            }
+                        }
+                        //涓昏〃鏈夋暟鎹� 瀛愯〃鏃犳暟鎹�
+                        if (j == SumDay - 1 && SumCount == 0 && HInterID != 0 && HBillNo != "")
+                        {
+                            objJsonResult = AddBillSub_SS(HInterID.ToString(),DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd").ToString()), 0);
+                        }
+                    }
+
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = null;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        //瀵煎叆瀛愯〃(涓夊崌)
+        public json AddBillSub_SS(string HInterID,DateTime date, int HQTY)
+        {
+            //鑾峰彇琛ㄦ牸鏁版嵁
+            ds = oCN.RunProcReturn($"select * from  h_v_JIT_Sc_WorkBillSortBillList where hmainid='{HInterID}'", "h_v_JIT_Sc_WorkBillSortBillList");
+            int count = 0;
+            if (ds.Tables[0].Rows.Count > 0)
+            {
+                //鍒ゆ柇瀛愯〃鏄惁鏈夊綋鏃ョ殑鏃ユ湡浠ュ強鏃ユ湡鎵�瀵瑰簲鐨勬暟閲�
+                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}" +
+                            $"  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)" +
+                            $"values({HInterID}, {(ds.Tables[0].Rows.Count + 1)}," +
+                            $" '{date}', {HQTY})");
+            }
+
+            objJsonResult.code = "1";
+            objJsonResult.count = 1;
+            objJsonResult.Message = null;
+            objJsonResult.data = null;
+            return objJsonResult;
+        }
+
+
+        #endregion
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1