From 6738bfc4d55d8948e87cd78a2341cf4f988431f8 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期一, 20 五月 2024 15:13:14 +0800 Subject: [PATCH] Smt上料一些更新 --- Tiger.Business/MES/SMT/Biz.SmtTool.cs | 136 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 135 insertions(+), 1 deletions(-) diff --git a/Tiger.Business/MES/SMT/Biz.SmtTool.cs b/Tiger.Business/MES/SMT/Biz.SmtTool.cs index a9cccb2..2fc34f6 100644 --- a/Tiger.Business/MES/SMT/Biz.SmtTool.cs +++ b/Tiger.Business/MES/SMT/Biz.SmtTool.cs @@ -13,6 +13,8 @@ using static Tiger.Business.Biz; using Microsoft.AspNetCore.Http; using System.Collections; +using System.Data; +using Sundial; namespace Tiger.Business { @@ -28,7 +30,7 @@ /// </summary> /// <param name="paras"></param> /// <returns></returns> - public async Task<ApiAction<List<SMT_WO_TABLE>>> GetNotLoadingMaterial(smtWoTableParams paras) + public async Task<ApiAction<List<SMT_WO_TABLE>>> GetNotLoadingMaterial(SmtLoadingInput paras) { var res = new ApiAction<List<SMT_WO_TABLE>>(); List<SMT_WO_TABLE> sList = new List<SMT_WO_TABLE>(); @@ -55,6 +57,138 @@ res.Data = sList; return await Task.FromResult(res); } + /// <summary> + /// 瀵煎叆宸ュ崟鏂欑珯琛� + /// </summary> + /// <param name="paras"></param> + /// <returns></returns> + public async Task<ApiAction<List<smtWoTableIn>>> ValidateTableImport(List<smtWoTableIn> paras) + { + var result = new ApiAction<List<smtWoTableIn>>(); + try + { + + //DataTable dt = JsonConvert.DeserializeObject<DataTable>(paras.ToString()); + List<smtWoTableIn> currentList = new List<smtWoTableIn>(); + if (paras.Count > 0) + { + var duplicateWo = paras.GroupBy(p => p.鍏宠仈宸ュ崟鍙�) + .Where(g => g.Count() > 1) + .Select(g => g.Key) + .ToList(); + if (duplicateWo.Count() > 0)//瀛樺湪閲嶅鏁版嵁 + { + string WORK_ORDER = string.Empty; + foreach (var item in duplicateWo) + { + WORK_ORDER += item; + } + WORK_ORDER = WORK_ORDER.TrimEnd(';'); + result.IsSuccessed = false; + result.Message = $"瀵煎叆鐨勭墿鏂欎腑鏈夐噸澶嶆暟鎹細鍏宠仈宸ュ崟锛歿WORK_ORDER}"; + } + else + { + foreach (var item in paras) + { + item.澶勭悊鏂瑰紡 = "鏂板"; + item.鍘熷洜 = null; + if (item.鍏宠仈宸ュ崟鍙� == null) + { + item.澶勭悊鏂瑰紡 = "鏁版嵁寮傚父"; + item.鍘熷洜 += "宸ュ崟鍙风┖鎴栦笉瀛樺湪锛�"; + } + if (item.浜у搧缂栫爜 == null) + { + item.澶勭悊鏂瑰紡 = "鏁版嵁寮傚父"; + item.鍘熷洜 += $"浜у搧缂栫爜涓虹┖锛�"; + } + currentList.Add(item); + if (await Db.Queryable<SMT_WO_TABLE>().AnyAsync(x => x.WORK_ORDER == item.鍏宠仈宸ュ崟鍙�)) + { + item.澶勭悊鏂瑰紡 = "淇敼"; + item.鍘熷洜 += $"宸ュ崟{item.鍏宠仈宸ュ崟鍙穧涓庢暟鎹簱閲嶅锛�"; + } + } + //for (int i = 0; i < item..Count; i++) + { + } + + } + } + result.Data = currentList; + + } + catch (Exception ex) + { + result.CatchException(ex, $"楠岃瘉瀵煎叆鍙戞枡璁″垝鎺掔▼寮傚父"); + } + return result; + } + /// <summary> + /// 瀵煎叆宸ュ崟鏂欑珯琛� + /// </summary> + /// <param name="paras"></param> + /// <returns></returns> + public async Task<ApiAction> SaveValidateTableImport(List<smtWoTableIn> paras) + { + var result = new ApiAction(); + try + { + + //DataTable dt = JsonConvert.DeserializeObject<DataTable>(paras.ToString()); + List<SMT_WO_TABLE> currentList = new List<SMT_WO_TABLE>(); + if (paras.Count > 0) + { + var db = Biz.Db; + foreach (var item in paras) + { + var workorder = item.鍏宠仈宸ュ崟鍙�.ToString(); + var id = db.Queryable<SMT_WO_TABLE>().Where(s => s.WORK_ORDER == workorder).Select(q => q.ID).First(); + SMT_WO_TABLE table = new SMT_WO_TABLE(); + table.ID= item.澶勭悊鏂瑰紡?.ToString()=="鏂板"?Guid.NewGuid().ToString():id; + table.CREATE_TIME = DateTime.Now; + table.UPDATE_TIME = DateTime.Now; + table.WORK_ORDER = item.鍏宠仈宸ュ崟鍙�.ToString(); + table.PROD_CODE = item.浜у搧缂栫爜?.ToString(); + table.ITEM_CODE = item.鐗╂枡缂栫爜?.ToString(); + table.SUBITEM_CODE = item.鏇夸唬鏂�?.ToString(); + table.UNIT = item.鍗曚綅?.ToString(); + table.UNIT_QTY = item.鍗曚綅鐢ㄩ噺.ToInt32(); + table.LINE_CODE = item.浜х嚎缂栫爜?.ToString(); + table.SMT_CODE = item.璐寸墖鏈虹紪鐮�?.ToString(); + table.SMT_STENCIL = item.閽㈢綉缂栫爜?.ToString(); + table.SLOT_NO = item.绔欎綅鍙�?.ToString(); + table.LOCATION = item.璐寸墖浣嶇疆?.ToString(); + table.FEEDER_CODE = item.椋炶揪缂栫爜?.ToString(); + table.FEEDER_TYPE = item.椋炶揪绫诲瀷?.ToString(); + table.PCB_SURFACE = item.鍔犲伐闈�?.ToString(); + table.LOAD_SEQ = item.涓婃枡椤哄簭.ToInt32(); + table.REMARK = item.澶囨敞?.ToString(); + table.VALIDATION_TYPE = item.澶勭悊鏂瑰紡?.ToString(); + table.VALIDATION_RESULT = item.鍘熷洜?.ToString(); + currentList.Add(table); + } + var add = currentList.Where(q => q.VALIDATION_TYPE == "鏂板").ToList(); + var upd = currentList.Where(q => q.VALIDATION_TYPE == "淇敼").ToList(); + if(add.Count > 0) + { + Biz.Db.Insertable(add).ExecuteCommand(); + } + if (upd.Count > 0) + { + Biz.Db.Updateable(upd).ExecuteCommand(); + } + + } + + } + catch (Exception ex) + { + result.CatchException(ex, $"楠岃瘉瀵煎叆宸ュ崟鏂欑珯琛ㄥ紓甯�"); + } + return result; + } } } } -- Gitblit v1.9.3