From 33736f197bd734a2b2e70395d6cc3cc674e89bb4 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期一, 17 十一月 2025 09:17:07 +0800
Subject: [PATCH] 1.生产入库信息查询接口增加是否源单查询字段 2.报表增加MES入库记录删除接口 3.增加存货档案关联工艺查询多存货 4.增加存货档案关联工艺提交多存货 4.通用基础资料中:仓库基础资料接口增加noid(erp中的仓库id)

---
 VueWebCoreApi/DLL/BLL/ReportManagerBLL.cs            |    7 
 VueWebCoreApi/DLL/BLL/WorkOrderBLL.cs                |    4 
 VueWebCoreApi/DLL/DAL/ProductModelDAL.cs             |  342 ++++++++++++++++++++++++++++++++++
 VueWebCoreApi/DLL/DAL/ReportManagerDAL.cs            |   43 ++++
 VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs                |   67 +++++-
 VueWebCoreApi/Models/MaterialRoutList.cs             |   25 ++
 VueWebCoreApi/Controllers/ProductModelController.cs  |   34 +++
 VueWebCoreApi/DLL/DAL/GeneralBasicDataDAL.cs         |    2 
 VueWebCoreApi/Controllers/WorkOrderController.cs     |    5 
 VueWebCoreApi/DLL/BLL/ProductModelBLL.cs             |   14 +
 VueWebCoreApi/Controllers/ReportManagerController.cs |   18 +
 11 files changed, 538 insertions(+), 23 deletions(-)

diff --git a/VueWebCoreApi/Controllers/ProductModelController.cs b/VueWebCoreApi/Controllers/ProductModelController.cs
index 2354d08..d59300d 100644
--- a/VueWebCoreApi/Controllers/ProductModelController.cs
+++ b/VueWebCoreApi/Controllers/ProductModelController.cs
@@ -277,6 +277,23 @@
         }
         #endregion
 
+        #region[瀛樿揣妗f鍏宠仈宸ヨ壓(宸ヨ壓璺嚎/宸ュ簭)鏌ヨ澶氬瓨璐
+        /// <summary>
+        /// 瀛樿揣妗f鍏宠仈宸ヨ壓(宸ヨ壓璺嚎/宸ュ簭)鏌ヨ澶氬瓨璐�
+        /// </summary>
+        /// <param name="partcode">鐗╂枡缂栫爜</param>
+        /// <returns></returns>
+        [Route(template: "TMaterielFileAssociationRouteList")]
+        [HttpPost]
+        public JsonResult TMaterielFileAssociationRouteList(List<string> partcode)
+        {
+            var token = HttpContext.Request.Headers["Token"].ToString();
+            User us = JwtTools.Denocode(token.ToString());
+            mes = ProductModelBLL.TMaterielFileAssociationRouteList(partcode, us);
+            return Json(mes);
+        }
+        #endregion
+
         #region[瀛樿揣妗f鍏宠仈宸ヨ壓(宸ヨ壓璺嚎鎴栧伐搴�)鎻愪氦]
         /// <summary>
         /// 瀛樿揣妗f鍏宠仈宸ヨ壓(宸ヨ壓璺嚎鎴栧伐搴�)鎻愪氦
@@ -294,6 +311,23 @@
         }
         #endregion
 
+        #region[瀛樿揣妗f鍏宠仈宸ヨ壓(宸ヨ壓璺嚎鎴栧伐搴�)鎻愪氦澶氬瓨璐
+        /// <summary>
+        /// 瀛樿揣妗f鍏宠仈宸ヨ壓(宸ヨ壓璺嚎鎴栧伐搴�)鎻愪氦澶氬瓨璐�
+        /// </summary>
+        /// <param name="json">鎻愪氦鏁版嵁瀵硅薄</param>
+        /// <returns></returns>
+        [Route(template: "SaveTMaterielFileList")]
+        [HttpPost]
+        public JsonResult SaveTMaterielFileList(List<MaterialCraftsSave> json)
+        {
+            var token = HttpContext.Request.Headers["Token"].ToString();
+            User us = JwtTools.Denocode(token.ToString());
+            mes = ProductModelBLL.SaveTMaterielFileList(us, json);
+            return Json(mes);
+        }
+        #endregion
+
 
 
         #region[宸ュ崟浜у搧淇℃伅涓嬫媺妗嗘煡璇
diff --git a/VueWebCoreApi/Controllers/ReportManagerController.cs b/VueWebCoreApi/Controllers/ReportManagerController.cs
index 1eb168f..d78c234 100644
--- a/VueWebCoreApi/Controllers/ReportManagerController.cs
+++ b/VueWebCoreApi/Controllers/ReportManagerController.cs
@@ -722,6 +722,23 @@
         }
         #endregion
 
+        #region[MES鍏ュ簱璁板綍鍒犻櫎]
+        /// <summary>
+        /// MES鍏ュ簱璁板綍鍒犻櫎
+        /// </summary>
+        /// <param name="dt">鎻愪氦鏁版嵁</param>
+        /// <returns></returns>
+        [Route(template: "DeleteMesInStorageRecord")]
+        [HttpPost]
+        public JsonResult DeleteMesInStorageRecord(DataTable dt)
+        {
+            var token = HttpContext.Request.Headers["Token"].ToString();
+            User us = JwtTools.Denocode(token.ToString());
+            mes = ReportManagerBLL.DeleteMesInStorageRecord(dt, us);
+            return Json(mes);
+        }
+        #endregion
+
         #region[T+鍏ュ簱璁板綍鍒犻櫎]
         /// <summary>
         /// T+鍏ュ簱璁板綍鍒犻櫎
@@ -733,7 +750,6 @@
         public JsonResult DeleteInStorageRecord(DataTable dt)
         {
             var token = HttpContext.Request.Headers["Token"].ToString();
-            //var token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyY29kZSI6Ijk5OTkiLCJ1c2VybmFtZSI6Iuezu-e7n-euoeeQhuWRmCIsInN0b3JnX2NvZGUiOiIiLCJzdG9yZ19uYW1lIjoiIiwiaXNfc3lzdGVtX2FkbWluIjoiWSIsInJvbGVfY29kZSI6IiIsInJvbGVfZGF0YXBlcm1pc3Npb25zIjoiIiwidXNlcnR5cGUiOiJQQyIsInJlZGlza2V5IjoiTmV3TUVTTG9naW5Vc2VySURQQzk5OTkiLCJtZXNTZXR0aW5nIjoie1wicm91dGVcIjp0cnVlLFwiaXNPcmRlclwiOnRydWUsXCJkZXZpY2VcIjp0cnVlLFwidGVjaFwiOnRydWUsXCJ3b3JrT3JkZXJcIjp0cnVlLFwiZXZlcnlcIjpmYWxzZSxcImxhc3RcIjpmYWxzZX0iLCJ0aW1lb3V0IjoiMjAyNC0xMC0yNFQxMjozNTo1MC4zNDI1NzE2KzA4OjAwIn0.Nbc-1sXd4QLLsnj8wH9XC7iWEmP0wDG82gwLxIh94e4";
             User us = JwtTools.Denocode(token.ToString());
             mes = ReportManagerBLL.DeleteInStorageRecord(dt, us);
             return Json(mes);
diff --git a/VueWebCoreApi/Controllers/WorkOrderController.cs b/VueWebCoreApi/Controllers/WorkOrderController.cs
index bc32548..da766e5 100644
--- a/VueWebCoreApi/Controllers/WorkOrderController.cs
+++ b/VueWebCoreApi/Controllers/WorkOrderController.cs
@@ -890,6 +890,7 @@
         /// <summary>
         /// 鐢熶骇鍏ュ簱淇℃伅鏌ヨ
         /// </summary>
+        /// <param name="issouceorder">鏄惁婧愬崟(Y/N)</param>
         /// <param name="deptno">閮ㄩ棬缂栫爜(T8浣跨敤)</param>
         /// <param name="saleordercode">閿�鍞崟鍙�</param>
         /// <param name="wkshopcode">杞﹂棿缂栫爜</param>
@@ -901,9 +902,9 @@
         /// <returns></returns>
         [Route(template: "ProductInHouseOrderSearch")]
         [HttpGet]
-        public JsonResult ProductInHouseOrderSearch(string deptno, string saleordercode, string wkshopcode, string erpordercode = null, string mesordercode = null, string partcode = null, string partname = null, string partspec = null)
+        public JsonResult ProductInHouseOrderSearch(string issouceorder, string deptno, string saleordercode, string wkshopcode, string erpordercode = null, string mesordercode = null, string partcode = null, string partname = null, string partspec = null)
         {
-            mes = WorkOrderBLL.ProductInHouseOrderSearch(deptno, saleordercode, wkshopcode, erpordercode, mesordercode, partcode, partname, partspec);
+            mes = WorkOrderBLL.ProductInHouseOrderSearch(issouceorder,deptno, saleordercode, wkshopcode, erpordercode, mesordercode, partcode, partname, partspec);
             return Json(mes);
         }
         #endregion
diff --git a/VueWebCoreApi/DLL/BLL/ProductModelBLL.cs b/VueWebCoreApi/DLL/BLL/ProductModelBLL.cs
index d90377b..a6eebec 100644
--- a/VueWebCoreApi/DLL/BLL/ProductModelBLL.cs
+++ b/VueWebCoreApi/DLL/BLL/ProductModelBLL.cs
@@ -99,6 +99,13 @@
         }
         #endregion
 
+        #region[瀛樿揣妗f鍏宠仈宸ヨ壓(宸ヨ壓璺嚎鎴栧伐搴�)鏌ヨ澶氬瓨璐
+        public static ToMessage TMaterielFileAssociationRouteList(List<string> partcode, User us)
+        {
+            return ProductModelDAL.TMaterielFileAssociationRouteList(partcode, us);
+        }
+        #endregion
+
         #region[瀛樿揣妗f鍏宠仈宸ヨ壓(宸ヨ壓璺嚎鎴栧伐搴�)鎻愪氦]
         public static ToMessage SaveTMaterielFile(User us, List<MaterialCraftsSave> json)
         {
@@ -106,6 +113,13 @@
         }
         #endregion
 
+        #region[瀛樿揣妗f鍏宠仈宸ヨ壓(宸ヨ壓璺嚎鎴栧伐搴�)鎻愪氦澶氬瓨璐
+        public static ToMessage SaveTMaterielFileList(User us, List<MaterialCraftsSave> json)
+        {
+            return ProductModelDAL.SaveTMaterielFileList(us, json);
+        }
+        #endregion
+
 
 
         #region[宸ュ崟浜у搧淇℃伅涓嬫媺妗嗘煡璇
diff --git a/VueWebCoreApi/DLL/BLL/ReportManagerBLL.cs b/VueWebCoreApi/DLL/BLL/ReportManagerBLL.cs
index 157d51e..aaf8f4d 100644
--- a/VueWebCoreApi/DLL/BLL/ReportManagerBLL.cs
+++ b/VueWebCoreApi/DLL/BLL/ReportManagerBLL.cs
@@ -168,6 +168,13 @@
         }
         #endregion
 
+        #region[MES鍏ュ簱璁板綍鍒犻櫎]
+        public static ToMessage DeleteMesInStorageRecord(DataTable dt, User us)
+        {
+            return ReportManagerDAL.DeleteMesInStorageRecord(dt, us);
+        }
+        #endregion
+
         #region[T+鍏ュ簱璁板綍鍒犻櫎]
         public static ToMessage DeleteInStorageRecord(DataTable dt, User us)
         {
diff --git a/VueWebCoreApi/DLL/BLL/WorkOrderBLL.cs b/VueWebCoreApi/DLL/BLL/WorkOrderBLL.cs
index a456a2c..9bec231 100644
--- a/VueWebCoreApi/DLL/BLL/WorkOrderBLL.cs
+++ b/VueWebCoreApi/DLL/BLL/WorkOrderBLL.cs
@@ -292,9 +292,9 @@
         #endregion
 
         #region[鐢熶骇鍏ュ簱淇℃伅鏌ヨ]
-        public static ToMessage ProductInHouseOrderSearch(string deptno, string saleordercode, string wkshopcode, string erpordercode, string mesordercode, string partcode, string partname, string partspec)
+        public static ToMessage ProductInHouseOrderSearch(string issouceorder, string deptno, string saleordercode, string wkshopcode, string erpordercode, string mesordercode, string partcode, string partname, string partspec)
         {
-            return WorkOrderDAL.ProductInHouseOrderSearch(deptno, saleordercode, wkshopcode, erpordercode, mesordercode, partcode, partname, partspec);
+            return WorkOrderDAL.ProductInHouseOrderSearch(issouceorder, deptno, saleordercode, wkshopcode, erpordercode, mesordercode, partcode, partname, partspec);
         }
         #endregion
 
diff --git a/VueWebCoreApi/DLL/DAL/GeneralBasicDataDAL.cs b/VueWebCoreApi/DLL/DAL/GeneralBasicDataDAL.cs
index d117537..0c751a9 100644
--- a/VueWebCoreApi/DLL/DAL/GeneralBasicDataDAL.cs
+++ b/VueWebCoreApi/DLL/DAL/GeneralBasicDataDAL.cs
@@ -422,7 +422,7 @@
             try
             {
                 //鑾峰彇浠撳簱鏁版嵁
-                sql = @"select code,name from TSecStck";
+                sql = @"select noid,code,name from TSecStck";
                 var data = DapperHelper.selecttable(sql);
                 mes.code = "200";
                 mes.message = "鏌ヨ鎴愬姛!";
diff --git a/VueWebCoreApi/DLL/DAL/ProductModelDAL.cs b/VueWebCoreApi/DLL/DAL/ProductModelDAL.cs
index 180b3d3..612b45c 100644
--- a/VueWebCoreApi/DLL/DAL/ProductModelDAL.cs
+++ b/VueWebCoreApi/DLL/DAL/ProductModelDAL.cs
@@ -1122,6 +1122,206 @@
         }
         #endregion
 
+        #region[瀛樿揣妗f鍏宠仈宸ヨ壓(宸ヨ壓璺嚎鎴栧伐搴�)鏌ヨ澶氬瓨璐
+        public static ToMessage TMaterielFileAssociationRouteList(List<string> partcode, User us)
+        {
+            string sql = "";
+            var dynamicParams = new DynamicParameters();
+            List<MaterialRoutList> list = new List<MaterialRoutList>();
+            try
+            {
+                dynamic dynObj = JObject.Parse(us.mesSetting);
+                bool route = dynObj.route;
+                if (route) //宸ヨ壓璺嚎鐗�
+                {
+                    // 1. 鎵归噺鑾峰彇鎵�鏈夌墿鏂欑殑鍩虹淇℃伅
+                    var baseInfoSql = @"SELECT M.partcode, M.partname, M.default_route as default_routecode, R.name as default_routename  
+                     FROM TMateriel_Info M
+                     LEFT JOIN TFlw_Rout R ON M.default_route = R.code
+                     WHERE M.partcode IN @PartCodes";
+                    var baseInfos = DapperHelper.select<dynamic>(baseInfoSql, new { PartCodes = partcode }).ToDictionary(x => (string)x.partcode, x => x);
+                    if (!baseInfos.Any())
+                    {
+                        mes.code = "200";
+                        mes.message = "鏈壘鍒板搴旂殑鐗╂枡淇℃伅";
+                        mes.data = list;
+                        return mes;
+                    }
+                    // 2. 鎵归噺鑾峰彇鎵�鏈夌墿鏂欑殑宸ヨ壓璺嚎淇℃伅
+                    var routeSql = @"SELECT mi.partcode AS partcode,fr.code AS routecode,fr.name AS routename,
+                                   CASE 
+                                       WHEN mr.materiel_code IS NOT NULL THEN 'Y' 
+                                       ELSE 'N' 
+                                   END AS flag
+                                   FROM TMateriel_Info mi
+                                   CROSS JOIN TFlw_Rout fr  
+                                   LEFT JOIN  TMateriel_Route mr ON mi.partcode = mr.materiel_code AND fr.code = mr.route_code  
+                                   WHERE mi.partcode IN @PartCodes AND fr.enable = 'Y'
+                                   ORDER BY mi.partcode, fr.code";
+                    var allRoutes = DapperHelper.select<dynamic>(routeSql, new { PartCodes = partcode }).GroupBy(x => (string)x.partcode).ToDictionary(g => g.Key, g => g.ToList());
+
+                    // 3. 鎵归噺鑾峰彇鎵�鏈夊伐搴忎俊鎭紙涓�娆℃�ф煡璇級
+                    var allRouteCodes = allRoutes.Values
+                        .SelectMany(routes => routes.Select(r => (string)r.routecode))
+                        .Distinct()
+                        .ToList();
+
+                    Dictionary<string, DataTable> routeSteps = new Dictionary<string, DataTable>();
+
+                    if (allRouteCodes.Any())
+                    {
+                        var stepSql = @"SELECT A.rout_code as route_code, A.seq, B.stepcode, B.stepname, B.enable 
+                                        FROM TFlw_Rtdt A
+                                        INNER JOIN TStep B ON A.step_code = B.stepcode
+                                        WHERE A.rout_code IN @RouteCodes AND B.is_delete <> '1' 
+                                        ORDER BY A.rout_code, A.seq ASC";
+                        var allSteps = DapperHelper.select<dynamic>(stepSql, new { RouteCodes = allRouteCodes });
+                        // 灏嗗伐搴忔暟鎹寜宸ヨ壓璺嚎缂栫爜鍒嗙粍
+                        routeSteps = allSteps
+                            .GroupBy(x => (string)x.route_code)
+                            .ToDictionary(
+                                g => g.Key,
+                                g =>
+                                {
+                                    // 灏嗗姩鎬佺被鍨嬭浆鎹负DataTable锛堟牴鎹偍鍘熸湁浠g爜鐨勮繑鍥炵被鍨嬭皟鏁达級
+                                    var dt = new DataTable();
+                                    dt.Columns.Add("seq");
+                                    dt.Columns.Add("stepcode");
+                                    dt.Columns.Add("stepname");
+                                    dt.Columns.Add("enable");
+
+                                    foreach (var step in g.OrderBy(s => s.seq))
+                                    {
+                                        dt.Rows.Add(step.seq, step.stepcode, step.stepname, step.enable);
+                                    }
+                                    return dt;
+                                });
+                    }
+                    // 4. 鍦ㄥ唴瀛樹腑缁勫悎鏁版嵁
+                    foreach (var part in partcode)
+                    {
+                        if (!baseInfos.ContainsKey(part)) continue;
+
+                        var baseInfo = baseInfos[part];
+                        var routlist = new MaterialRoutList
+                        {
+                            partcode = baseInfo.partcode,
+                            partname = baseInfo.partname,
+                            defalutroutecode = baseInfo.default_routecode,
+                            defalutroutename = baseInfo.default_routename,
+                            children = new List<RouteList>()
+                        };
+
+                        // 娣诲姞璇ョ墿鏂欑殑宸ヨ壓璺嚎
+                        if (allRoutes.ContainsKey(part))
+                        {
+                            foreach (var routeInfo in allRoutes[part])
+                            {
+                                var rout = new RouteList
+                                {
+                                    routecode = routeInfo.routecode,
+                                    routename = routeInfo.routename,
+                                    flag = routeInfo.flag
+                                };
+
+                                // 娣诲姞宸ュ簭淇℃伅
+                                if (routeSteps.ContainsKey(rout.routecode))
+                                {
+                                    rout.Data = routeSteps[rout.routecode];
+                                }
+
+                                routlist.children.Add(rout);
+                            }
+                        }
+
+                        list.Add(routlist);
+                    }
+
+                    mes.data = list;
+                    mes.code = "200";
+                    mes.message = $"鏌ヨ鎴愬姛锛屽叡澶勭悊{list.Count}涓墿鏂�";
+                }
+                else //宸ュ簭鐗�
+                {
+                    // 1. 鎵归噺鑾峰彇鎵�鏈夌墿鏂欏熀纭�淇℃伅
+                    var baseInfoSql = @"SELECT partcode, partname FROM TMateriel_Info 
+                       WHERE partcode IN @PartCodes";
+                    var baseInfos = DapperHelper.select<dynamic>(baseInfoSql, new { PartCodes = partcode })
+                        .ToDictionary(x => (string)x.partcode, x => x);
+
+                    if (!baseInfos.Any())
+                    {
+                        mes.code = "200";
+                        mes.message = "鏈壘鍒板搴旂殑鐗╂枡淇℃伅";
+                        mes.data = new List<MaterialRoutList>();
+                        return mes;
+                    }
+
+                    // 2. 鎵归噺鑾峰彇鎵�鏈夌墿鏂欑殑宸ュ簭淇℃伅
+                    var stepSql = @"SELECT A.materiel_code as partcode, A.step_seq, A.step_code, 
+                           S.stepname, A.isbott, A.isend   
+                    FROM TMateriel_Step A
+                    INNER JOIN TStep S ON A.step_code = S.stepcode
+                    WHERE A.materiel_code IN @PartCodes AND S.is_delete <> '1'
+                    ORDER BY A.materiel_code, A.step_seq";
+
+                    var allSteps = DapperHelper.select<dynamic>(stepSql, new { PartCodes = partcode })
+                        .GroupBy(x => (string)x.partcode)
+                        .ToDictionary(g => g.Key, g => g.ToList());
+
+                    // 3. 鍐呭瓨涓粍鍚堟暟鎹�
+                    foreach (var part in partcode)
+                    {
+                        if (!baseInfos.ContainsKey(part)) continue;
+
+                        var baseInfo = baseInfos[part];
+                        var routlist = new MaterialRoutList
+                        {
+                            partcode = baseInfo.partcode,
+                            partname = baseInfo.partname,
+                            children = new List<RouteList>()
+                        };
+
+                        // 娣诲姞宸ュ簭淇℃伅
+                        if (allSteps.ContainsKey(part))
+                        {
+                            // 杞崲涓篋ataTable锛堝闇�淇濇寔鍘熸湁缁撴瀯锛�
+                            var stepData = allSteps[part];
+                            var dataTable = new DataTable();
+                            dataTable.Columns.Add("step_seq");
+                            dataTable.Columns.Add("step_code");
+                            dataTable.Columns.Add("step_name");
+                            dataTable.Columns.Add("isbott");
+                            dataTable.Columns.Add("isend");
+
+                            foreach (var step in stepData.OrderBy(s => s.step_seq))
+                            {
+                                dataTable.Rows.Add(step.step_seq, step.step_code,
+                                                 step.stepname, step.isbott, step.isend);
+                            }
+
+                            routlist.children.Add(new RouteList { Data = dataTable });
+                        }
+
+                        list.Add(routlist);
+                    }
+
+                    mes.data = list;
+                    mes.code = "200";
+                    mes.message = $"鏌ヨ鎴愬姛锛屽叡澶勭悊{list.Count}涓墿鏂�";
+                }
+            }
+            catch (Exception e)
+            {
+                mes.code = "300";
+                mes.count = 0;
+                mes.message = e.Message;
+                mes.data = null;
+            }
+            return mes;
+        }
+        #endregion
+
         #region[瀛樿揣妗f鍏宠仈宸ヨ壓(宸ヨ壓璺嚎鎴栧伐搴�)鎻愪氦]
         public static ToMessage SaveTMaterielFile(User us, List<MaterialCraftsSave> json)
         {
@@ -1258,6 +1458,148 @@
         }
         #endregion
 
+        #region[瀛樿揣妗f鍏宠仈宸ヨ壓(宸ヨ壓璺嚎鎴栧伐搴�)鎻愪氦澶氬瓨璐
+        public static ToMessage SaveTMaterielFileList(User us, List<MaterialCraftsSave> json)
+        {
+            var sql = "";
+            List<object> list = new List<object>();
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                list.Clear();
+                dynamic dynObj = JObject.Parse(us.mesSetting);
+                bool route = dynObj.route;
+                if (route) //宸ヨ壓璺嚎鐗�
+                {
+                    for (int i = 0; i < json.Count; i++)
+                    {
+                        if (json[i].children == null || json[i].children.Count <= 0)
+                        {
+                            //娓呴櫎鐗╂枡鍏宠仈宸ヨ壓璺嚎琛ㄦ暟鎹�
+                            sql = @"delete TMateriel_Route where materiel_code=@partcode";
+                            list.Add(new { str = sql, parm = new { partcode = json[i].partcode } });
+                            //鏍囪鐗╂枡琛ㄥ叧鑱斿伐鑹鸿矾绾挎爣璇�
+                            sql = @"update TMateriel_Info set is_retdproc='N',default_route='' where partcode=@partcode";
+                            list.Add(new { str = sql, parm = new { partcode = json[i].partcode } });
+                            //娓呴櫎鑺傛媿宸ヤ环琛ㄥ搴旀暟鎹�
+                            sql = @"delete TPrteEqp_Stad where materiel_code=@partcode";
+                            list.Add(new { str = sql, parm = new { partcode = json[i].partcode } });
+                        }
+                        else
+                        {
+                            //娓呴櫎瀛樿揣鍏宠仈宸ヨ壓璺嚎琛ㄦ暟鎹�
+                            sql = @"delete TMateriel_Route where materiel_code=@partcode";
+                            list.Add(new { str = sql, parm = new { partcode = json[i].partcode } });
+                            //寰幆鍐欏叆瀛樿揣鍏宠仈宸ヨ壓璺嚎琛�
+                            for (int j = 0; j < json[i].children.Count; j++)
+                            {
+                                sql = @"insert into TMateriel_Route(materiel_code,route_code,lm_user,lm_date) values(@materiel_code,@route_code,@lm_user,@lm_date)";
+                                list.Add(new
+                                {
+                                    str = sql,
+                                    parm = new
+                                    {
+                                        materiel_code = json[i].partcode,
+                                        route_code = json[i].children[j].code,
+                                        lm_user = us.usercode,
+                                        lm_date = DateTime.Now.ToString()
+                                    }
+                                });
+                            }
+                            //鏍囪鐗╂枡琛ㄥ叧鑱斿伐鑹鸿矾绾挎爣璇�
+                            sql = @"update TMateriel_Info set is_retdproc='Y',default_route=@defaultroute_code where partcode=@partcode";
+                            list.Add(new { str = sql, parm = new { partcode = json[i].partcode, defaultroute_code = json[i].defaultroute_code } });
+
+                            //娓呴櫎鑺傛媿宸ヤ环琛ㄥ綋鍓嶄骇鍝佸搴斿伐鑹鸿矾绾夸笉鍖呭惈姝ゆ璁剧疆鐨勫叾瀹冩暟鎹�
+                            //string鍒嗗壊杞瑂tring[]
+                            string[] routcode = Array.ConvertAll<string, string>(string.Join(",", json[i].children.Select(s => s.code)).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString());
+                            sql = @"delete TPrteEqp_Stad where materiel_code=@partcode and route_code not in @routecode";
+                            list.Add(new { str = sql, parm = new { partcode = json[i].partcode, routecode = routcode } });
+                        }
+                    }
+                }
+                else //宸ュ簭鐗�
+                {
+                    for (int i = 0; i < json.Count; i++)
+                    {
+                        if (json[i].children == null || json[i].children.Count <= 0)
+                        {
+                            //娓呴櫎鐗╂枡鍏宠仈宸ヨ壓璺嚎琛ㄦ暟鎹�
+                            sql = @"delete TMateriel_Step where materiel_code=@partcode";
+                            list.Add(new { str = sql, parm = new { partcode = json[i].partcode } });
+                            //鏍囪鐗╂枡琛ㄥ叧鑱斿伐鑹鸿矾绾挎爣璇�
+                            sql = @"update TMateriel_Info set is_retdproc='N',default_route='' where partcode=@partcode";
+                            list.Add(new { str = sql, parm = new { partcode = json[i].partcode } });
+                            //娓呴櫎鑺傛媿宸ヤ环琛ㄥ搴旀暟鎹�
+                            sql = @"delete TPrteEqp_Stad where materiel_code=@partcode";
+                            list.Add(new { str = sql, parm = new { partcode = json[i].partcode } });
+                        }
+                        else
+                        {
+                            //娓呴櫎瀛樿揣鍏宠仈宸ヨ壓璺嚎琛ㄦ暟鎹�
+                            sql = @"delete TMateriel_Step where materiel_code=@partcode";
+                            list.Add(new { str = sql, parm = new { partcode = json[i].partcode } });
+                            //寰幆鍐欏叆瀛樿揣鍏宠仈宸ヨ壓璺嚎琛�
+                            for (int j = 0; j < json[i].children.Count; j++)
+                            {
+                                sql = @"insert into TMateriel_Step(materiel_code,step_seq,step_code,isbott,isend,lm_user,lm_date) 
+                                    values(@materiel_code,@step_seq,@step_code,@isbott,@isend,@lm_user,@lm_date)";
+                                list.Add(new
+                                {
+                                    str = sql,
+                                    parm = new
+                                    {
+                                        materiel_code = json[i].partcode,
+                                        step_seq = json[i].children[j].seq,
+                                        step_code = json[i].children[j].code,
+                                        isbott = json[i].children[j].isbott,
+                                        isend = json[i].children[j].isend,
+                                        lm_user = us.usercode,
+                                        lm_date = DateTime.Now.ToString()
+                                    }
+                                });
+                            }
+                            //鏍囪鐗╂枡琛ㄥ叧鑱斿伐鑹鸿矾绾挎爣璇�
+                            sql = @"update TMateriel_Info set is_retdproc='Y',default_route=@defaultroute_code where partcode=@partcode";
+                            list.Add(new { str = sql, parm = new { partcode = json[i].partcode, defaultroute_code = json[i].defaultroute_code } });
+
+                            //娓呴櫎鑺傛媿宸ヤ环琛ㄥ綋鍓嶄骇鍝佸搴斿伐搴忎笉鍖呭惈姝ゆ璁剧疆鐨勫叾瀹冩暟鎹�
+                            //string鍒嗗壊杞瑂tring[]
+                            string[] stepcode = Array.ConvertAll<string, string>(string.Join(",", json[i].children.Select(s => s.code)).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), s => s.ToString());
+                            sql = @"delete TPrteEqp_Stad where materiel_code=@partcode and step_code not in @stepcode";
+                            list.Add(new { str = sql, parm = new { partcode = json[i].partcode, stepcode = stepcode } });
+                        }
+                    }
+                }
+                bool aa = DapperHelper.DoTransaction(list);
+                if (aa)
+                {
+                    //鍐欏叆鎿嶄綔璁板綍琛�
+                    LogHelper.DbOperateLog(us.usercode, "瀛樿揣鍏宠仈宸ヨ壓", "浜у搧锛�" + string.Join(",", json.Select(x => x.partcode)) + "鍏宠仈浜嗗伐鑹�:" + string.Join(",", json.SelectMany(x => x.children?.Select(c => c.code) ?? Enumerable.Empty<string>())), us.usertype);
+                    mes.code = "200";
+                    mes.count = 0;
+                    mes.message = "鎿嶄綔鎴愬姛!";
+                    mes.data = null;
+                }
+                else
+                {
+                    mes.code = "300";
+                    mes.count = 0;
+                    mes.message = "鎿嶄綔澶辫触!";
+                    mes.data = null;
+                }
+            }
+            catch (Exception e)
+            {
+                mes.code = "300";
+                mes.count = 0;
+                mes.message = e.Message;
+                mes.data = null;
+            }
+            return mes;
+        }
+        #endregion
+
 
         #region[宸ュ崟浜у搧淇℃伅涓嬫媺妗嗘煡璇
         public static ToMessage PartSelect()
diff --git a/VueWebCoreApi/DLL/DAL/ReportManagerDAL.cs b/VueWebCoreApi/DLL/DAL/ReportManagerDAL.cs
index f82bbc3..406b479 100644
--- a/VueWebCoreApi/DLL/DAL/ReportManagerDAL.cs
+++ b/VueWebCoreApi/DLL/DAL/ReportManagerDAL.cs
@@ -1877,6 +1877,49 @@
         }
         #endregion
 
+        #region[MES鍏ュ簱璁板綍鍒犻櫎]
+        public static ToMessage DeleteMesInStorageRecord(DataTable dt, User us)
+        {
+            var sql = "";
+            var dynamicParams = new DynamicParameters();
+            try
+            {
+                //瀛樺偍杩囩▼鍚�
+                sql = @"h_p_IFCLD_DeleteInProductOrder";
+                dynamicParams.Add("@RecordSub", dbType: DbType.Object, value: dt);
+                // 娣诲姞杈撳嚭鍙傛暟  
+                dynamicParams.Add("@StatusCode", dbType: DbType.Int32, direction: ParameterDirection.Output);
+                dynamicParams.Add("@Message", dbType: DbType.String, size: 255, direction: ParameterDirection.Output);
+                bool a = DapperHelper.IsProcedure(sql, dynamicParams);
+                // 鑾峰彇杈撳嚭鍙傛暟鐨勫��  
+                var statusCode = dynamicParams.Get<int>("@StatusCode");
+                var message = dynamicParams.Get<string>("@Message");
+                if (a)
+                {
+                    mes.code = statusCode.ToString();
+                    mes.count = 0;
+                    mes.message = message;
+                    mes.data = null;
+                }
+                else
+                {
+                    mes.code = statusCode.ToString();
+                    mes.count = 0;
+                    mes.message = message;
+                    mes.data = null;
+                }
+            }
+            catch (Exception e)
+            {
+                mes.code = "300";
+                mes.count = 0;
+                mes.message = e.Message;
+                mes.data = null;
+            }
+            return mes;
+        }
+        #endregion
+
         #region[T+鍏ュ簱璁板綍鍒犻櫎]
         public static ToMessage DeleteInStorageRecord(DataTable dt, User us)
         {
diff --git a/VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs b/VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs
index 248f8f8..f20820a 100644
--- a/VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs
+++ b/VueWebCoreApi/DLL/DAL/WorkOrderDAL.cs
@@ -609,30 +609,47 @@
             var dynamicParams = new DynamicParameters();
             try
             {
-                sql = @"select *  from TK_Wrk_Man where m_po=@erpordercode and status<> 'CLOSED'";
+                sql = @"select *  from TK_Wrk_Man where m_po=@erpordercode and sourceid=@sourceid";
                 dynamicParams.Add("@erpordercode", erpordercode);
+                dynamicParams.Add("@sourceid", erporderid);
                 var data = DapperHelper.selectdata(sql, dynamicParams);
                 if (data.Rows.Count > 0)
                 {
-                    mes.code = "300";
-                    mes.count = 0;
-                    mes.message = "褰撳墠璁㈠崟鏈変笅杈炬湭鍏抽棴鐨凪ES宸ュ崟,璁㈠崟涓嶅厑璁稿叧闂�,璇峰厛鍒犻櫎鎴栧叧闂浉鍏冲伐鍗�!";
-                    mes.data = null;
-                }
-                else
-                {
-                    //鍏抽棴璁㈠崟
-                    sql = @"update  TKimp_Ewo set status='CLOSED' where wo=@wo and id=@erporderid";
+                    // 浣跨敤LINQ鍜宭ambda琛ㄨ揪寮忔潵杞崲wo_code瀛楁鐨勫�间负閫楀彿闅斿紑鐨勫瓧绗︿覆鏁扮粍  
+                    string[] result = data.AsEnumerable().Select(row => "" + row.Field<string>("wo_code") + "").ToArray();
+                    //鍏抽棴宸ュ簭浠诲姟
+                    sql = @"update  TK_Wrk_Step set status='CLOSED',closebeforestatus=status where wo_code in @wocode";
                     list.Add(new
                     {
                         str = sql,
                         parm = new
                         {
-                            wo = erpordercode,
-                            erporderid = erporderid
+                            wocode = result
+                        }
+                    });
+                    //鍏抽棴宸ュ崟
+                    sql = @"update  TK_Wrk_Man set status='CLOSED',closebeforestatus=status where m_po=@erpordercode and sourceid=@sourceid";
+                    list.Add(new
+                    {
+                        str = sql,
+                        parm = new
+                        {
+                            erpordercode = erpordercode,
+                            sourceid = erporderid
                         }
                     });
                 }
+                //鍏抽棴璁㈠崟
+                sql = @"update  TKimp_Ewo set status='CLOSED',closebeforestatus=status where wo=@wo and id=@erporderid";
+                list.Add(new
+                {
+                    str = sql,
+                    parm = new
+                    {
+                        wo = erpordercode,
+                        erporderid = erporderid
+                    }
+                });
                 bool aa = DapperHelper.DoTransaction(list);
                 if (aa)
                 {
@@ -910,7 +927,7 @@
                 }
                 // --------------鏌ヨ鎸囧畾鏁版嵁--------------
                 var total = 0; //鎬绘潯鏁�
-                var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.route_code,B.default_route,R.name as route_name,A.plan_qty,A.wkshp_code,C.torg_name as wkshp_name,
+                var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.idTopInventory,A.TopInventoryCode,A.TopInventoryName,A.route_code,B.default_route,R.name as route_name,A.plan_qty,A.wkshp_code,C.torg_name as wkshp_name,
                             A.stck_code,D.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,A.saleOrderDeliveryDate,W.saleOrderCode,U.username as lm_user,A.lm_date,A.data_sources,A.isstep,A.clerkuser,
                             B.priuserdefnvc1,B.priuserdefnvc2,B.priuserdefnvc3,B.priuserdefnvc4,B.priuserdefnvc5,B.priuserdefnvc6,A.printcount
                             from TK_Wrk_Man A
@@ -998,7 +1015,7 @@
                 }
                 // --------------鏌ヨ鎸囧畾鏁版嵁--------------
                 var total = 0; //鎬绘潯鏁�
-                var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.plan_qty,A.wkshp_code,C.torg_name as wkshp_name,
+                var sql = @"select A.id, A.status,A.wotype,A.wo_code,A.materiel_code as partcode,B.partname,B.partspec,A.idTopInventory,A.TopInventoryCode,A.TopInventoryName,A.plan_qty,A.wkshp_code,C.torg_name as wkshp_name,
                             A.stck_code,D.name as stck_name,A.plan_startdate,A.plan_enddate,A.piroque,A.sourceid,A.m_po,A.saleOrderDeliveryDate,W.saleOrderCode,U.username as lm_user,A.lm_date,S.laborbad_qty,S.materielbad_qty,
                             B.priuserdefnvc1,B.priuserdefnvc2,B.priuserdefnvc3,B.priuserdefnvc4,B.priuserdefnvc5,B.priuserdefnvc6
                             from TK_Wrk_Man A
@@ -4663,12 +4680,26 @@
         #endregion
 
         #region[鐢熶骇鍏ュ簱淇℃伅鏌ヨ]
-        public static ToMessage ProductInHouseOrderSearch(string deptno, string saleordercode, string wkshopcode, string erpordercode, string mesordercode, string partcode, string partname, string partspec)
+        public static ToMessage ProductInHouseOrderSearch(string issouceorder, string deptno, string saleordercode, string wkshopcode, string erpordercode, string mesordercode, string partcode, string partname, string partspec)
         {
             var dynamicParams = new DynamicParameters();
             string search = "";
             try
             {
+                if (issouceorder != "" && issouceorder != null)
+                {
+                    switch (issouceorder)
+                    {
+                        case "Y":
+                            search += " and AA.m_po<>'' ";
+                            break;
+                        case "N":
+                            search += " and AA.m_po='' ";
+                            break;
+                        default:
+                            break;
+                    }
+                }
                 if (deptno != "" && deptno != null)
                 {
                     search += "and AA.dept_code=@deptno ";
@@ -4714,7 +4745,8 @@
                 var sql = @"select *   from(
                               select A.inbarcode,E.saleOrderid,isnull(E.saleOrderCode,'') as saleOrderCode,E.saleOrderDetailId,E.woid as mpoid,M.m_po,E.sbid,M.id as wo_id,A.wo_code,E.materiel_id,P.partcode,P.partname,P.partspec,E.unitid,E.unitcode,E.unitname,
                               A.step_code,T.stepname,M.wkshp_code,O.torg_name as wkshp_name,COALESCE(K.noid, E.stck_id) as stockid,COALESCE(K.code, E.stck_code) as stockcode,k.name as stockname,E.dept_id,E.dept_code,
-                              E.saleOrderqty,E.qty,M.plan_qty,A.good_qty,isnull(A.inhouseqty,0) as inhouseqty,A.good_qty-isnull(A.inhouseqty,0) as stinhouseqty,M.lm_date,A.style,E.voucherdate   
+                              E.saleOrderqty,E.qty,M.plan_qty,A.good_qty,isnull(A.inhouseqty,0) as inhouseqty,A.good_qty-isnull(A.inhouseqty,0) as stinhouseqty,M.lm_date,A.style,
+                              (case when E.voucherdate is null then M.lm_date else E.voucherdate end) as voucherdate 
                               from  TK_Wrk_Record A
                               inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
                               inner join TK_Wrk_Man M on S.wo_code=M.wo_code
@@ -4727,7 +4759,8 @@
                               union all
                               select A.inbarcode,E.saleOrderid,isnull(E.saleOrderCode,'') as saleOrderCode,E.saleOrderDetailId,E.woid as mpoid,M.m_po,E.sbid,M.id as wo_id,A.wo_code,E.materiel_id,P.partcode,P.partname,P.partspec,E.unitid,E.unitcode,E.unitname,
                               A.step_code,T.stepname,M.wkshp_code,O.torg_name as wkshp_name,COALESCE(K.noid, E.stck_id) as stockid,COALESCE(K.code, E.stck_code) as stockcode,k.name as stockname,E.dept_id,E.dept_code,
-                              E.saleOrderqty,E.qty,M.plan_qty,A.sqty as sqty,isnull(A.inhouseqty,0) as inhouseqty,A.sqty-isnull(A.inhouseqty,0) as stinhouseqty,M.lm_date,A.style,E.voucherdate   
+                              E.saleOrderqty,E.qty,M.plan_qty,A.sqty as sqty,isnull(A.inhouseqty,0) as inhouseqty,A.sqty-isnull(A.inhouseqty,0) as stinhouseqty,M.lm_date,A.style,
+                              (case when E.voucherdate is null then M.lm_date else E.voucherdate end) as voucherdate 
                               from  TK_Wrk_OutRecord A
                               inner join TK_Wrk_Step S on A.wo_code=S.wo_code and A.step_code=S.step_code
                               inner join TK_Wrk_Man M on S.wo_code=M.wo_code
diff --git a/VueWebCoreApi/Models/MaterialRoutList.cs b/VueWebCoreApi/Models/MaterialRoutList.cs
new file mode 100644
index 0000000..b8dd0dc
--- /dev/null
+++ b/VueWebCoreApi/Models/MaterialRoutList.cs
@@ -0,0 +1,25 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace VueWebCoreApi.Models
+{
+    public class MaterialRoutList
+    {
+        public string partcode { get; set; }
+        public string partname { get; set; }
+        public string defalutroutecode { get; set; }
+        public string defalutroutename { get; set; }
+        public List<RouteList> children { get; set; }
+
+    }
+    public class RouteList
+    {
+        public string routecode { get; set; }
+        public string routename { get; set; }
+        public string flag { get; set; }
+        public DataTable Data { get; set; }
+    }
+}

--
Gitblit v1.9.3