From 7e25ed322740ed337296a990bac67e95bc250ac0 Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期四, 30 五月 2024 22:32:43 +0800 Subject: [PATCH] 移出萌妻的类,增加实体查询的api方法 --- Tiger.Business/MES/Biz.Route.cs | 1 Tiger.Api/Controllers/Test/TestController.R.cs | 17 + Tiger.Business.MES/MES_WORKSHOP.cs | 7 Tiger.Api/Controllers/Base/SystemController.cs | 21 + Tiger.Business.MengQi/Mq.Customer.cs | 110 +++++++ Tiger.Business/Language/LanguageEntity.cs | 1 Tiger.Business/Tiger.Business.csproj | 1 Tiger.Api.sln | 11 Tiger.Business.MES/SMT/SmtTool.cs | 5 Tiger.Business.MES/BIZ_MES_WO.cs | 9 /dev/null | 142 ---------- Tiger.Business.MengQi/Mq.SNData.cs | 202 ++++++++++++++ Tiger.Business.MengQi/Mq.ModelInfo.cs | 96 ++++++ Tiger.Business.MengQi/User.cs | 140 ++++++++++ Tiger.Business.MengQi/Tiger.Business.MengQi.csproj | 18 + 15 files changed, 625 insertions(+), 156 deletions(-) diff --git a/Tiger.Api.sln b/Tiger.Api.sln index f1ddd9d..621e9fb 100644 --- a/Tiger.Api.sln +++ b/Tiger.Api.sln @@ -26,6 +26,8 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tiger.Business.MES", "Tiger.Business.MES\Tiger.Business.MES.csproj", "{3848BCAB-4E77-4D5E-8BF0-2A747981C1B4}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tiger.Business.MengQi", "Tiger.Business.MengQi\Tiger.Business.MengQi.csproj", "{DD5B5282-B673-45CB-8608-3AAEB4A469B9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -74,6 +76,14 @@ {3848BCAB-4E77-4D5E-8BF0-2A747981C1B4}.Release|Any CPU.Build.0 = Release|Any CPU {3848BCAB-4E77-4D5E-8BF0-2A747981C1B4}.Release|x86.ActiveCfg = Release|Any CPU {3848BCAB-4E77-4D5E-8BF0-2A747981C1B4}.Release|x86.Build.0 = Release|Any CPU + {DD5B5282-B673-45CB-8608-3AAEB4A469B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DD5B5282-B673-45CB-8608-3AAEB4A469B9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DD5B5282-B673-45CB-8608-3AAEB4A469B9}.Debug|x86.ActiveCfg = Debug|Any CPU + {DD5B5282-B673-45CB-8608-3AAEB4A469B9}.Debug|x86.Build.0 = Debug|Any CPU + {DD5B5282-B673-45CB-8608-3AAEB4A469B9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DD5B5282-B673-45CB-8608-3AAEB4A469B9}.Release|Any CPU.Build.0 = Release|Any CPU + {DD5B5282-B673-45CB-8608-3AAEB4A469B9}.Release|x86.ActiveCfg = Release|Any CPU + {DD5B5282-B673-45CB-8608-3AAEB4A469B9}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -84,6 +94,7 @@ {E7540FE4-F284-4F66-A11C-24D846C4B558} = {FF44BF62-08C5-4B52-B24F-54CD79E96848} {60FA322B-9B03-4380-803C-63B1F240E453} = {70881CAB-17ED-4C46-895A-62F2CE39A607} {3848BCAB-4E77-4D5E-8BF0-2A747981C1B4} = {70881CAB-17ED-4C46-895A-62F2CE39A607} + {DD5B5282-B673-45CB-8608-3AAEB4A469B9} = {70881CAB-17ED-4C46-895A-62F2CE39A607} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {797A1D83-9F3C-4AEC-8A83-E3468102DBD1} diff --git a/Tiger.Api/Controllers/Base/SystemController.cs b/Tiger.Api/Controllers/Base/SystemController.cs index 583d104..04d0f00 100644 --- a/Tiger.Api/Controllers/Base/SystemController.cs +++ b/Tiger.Api/Controllers/Base/SystemController.cs @@ -7,6 +7,7 @@ using Rhea.Common; using Tiger.IBusiness; using System.Threading; +using System.Linq; namespace Tiger.Api.Controllers.Base { @@ -95,6 +96,26 @@ } /// <summary> + /// 鑾峰彇Api浜у搧 + /// </summary> + /// <returns></returns> + [HttpGet] + [Route("System/Base/[action]")] + public IActionResult GetEntitys() + { + Assembly assembly = Assembly.Load("Tiger.Model"); + Type[] types = assembly.GetTypes(); + var entitys = types.Where(q => q.GetInterfaces().Contains(typeof(Model.iEntity)) && q.IsClass).ToList(); + var data = entitys.Select(q => new + { + q.Namespace, + q.FullName, + Properties = q.GetProperties().Select(p => new { p.Name, Type = p.PropertyType.Name }).ToList() + }); + return Ok(data); + } + + /// <summary> /// GetCertification(ApiAction) /// 鍦ㄦ敞鍐岃〃HKEY_LOCAL_MACHINE\SOFTWARE\TigerClouds鑺傜偣涓鍙栧瘑閽ヨ瘉涔� /// </summary> diff --git a/Tiger.Api/Controllers/Test/TestController.R.cs b/Tiger.Api/Controllers/Test/TestController.R.cs index a9920e7..bce95fb 100644 --- a/Tiger.Api/Controllers/Test/TestController.R.cs +++ b/Tiger.Api/Controllers/Test/TestController.R.cs @@ -19,6 +19,8 @@ using Newtonsoft.Json.Linq; using Tiger.Api.iBiz; using System.Net; +using System.Reflection; +using Swifter.Tools; namespace Tiger.Api.Controllers.Test { @@ -37,6 +39,21 @@ return Ok(Biz.Db.DbMaintenance.GetTableInfoList()); } + [HttpGet] + public IActionResult GetEntitys(string AssemblyName, string NameSpace) + { + Assembly assembly = Assembly.Load(AssemblyName); + Type[] types = assembly.GetTypes(); + var entitys = types.Where(q => q.GetInterfaces().Contains(typeof(iEntity)) && q.IsClass).ToList(); + var data = entitys.Select(q => new + { + q.Namespace, + q.FullName, + Properties = q.GetProperties().Select(p => new { p.Name, Type = p.PropertyType.Name }).ToList() + }); + return Ok(data); + } + /// <summary> /// GetAsync /// </summary> diff --git a/Tiger.Business.MES/BIZ_MES_WO.cs b/Tiger.Business.MES/BIZ_MES_WO.cs index d696680..2d18114 100644 --- a/Tiger.Business.MES/BIZ_MES_WO.cs +++ b/Tiger.Business.MES/BIZ_MES_WO.cs @@ -10,7 +10,6 @@ using System.Linq; using Newtonsoft.Json; using Tiger.IBusiness; -using static Tiger.Business.Biz; using Microsoft.AspNetCore.Http; namespace Tiger.Business.MES @@ -27,14 +26,14 @@ var result = new ApiAction(); try { - var _wo = Db.Queryable<BIZ_MES_WO>().Where(x => x.ORDER_NO == wo.ORDER_NO).First(); + var _wo = Biz.Db.Queryable<BIZ_MES_WO>().Where(x => x.ORDER_NO == wo.ORDER_NO).First(); if (_wo != null && _wo.STATUS != (int)BIZ_MES_WO.STATUSs.Init) { result.IsSuccessed = false; result.LocaleMsg = new($"宸ュ崟宸茬粡瀛樺湪涓斾笉鏄垵濮嬪寲鐘舵�侊紝涓嶈兘淇濆瓨淇敼锛�"); return result; } - var db = Db; + var db = Biz.Db; var dbTran = db.UseTran(() => { var y = db.Storageable(wo) @@ -67,14 +66,14 @@ try { //鏌ヨ鏄惁宸茬粡鏈夊伐鍗曞湪鐢� - var _wo = Db.Queryable<BIZ_MES_WO>().Where(x => x.ID == woId).First(); + var _wo = Biz.Db.Queryable<BIZ_MES_WO>().Where(x => x.ID == woId).First(); if (_wo != null && _wo.STATUS != (int)BIZ_MES_WO.STATUSs.Init) { result.IsSuccessed = false; result.LocaleMsg = new($"宸ュ崟涓嶆槸鍒濆鍖栫姸鎬侊紝涓嶈兘鍒犻櫎锛�"); return result; } - var db = Db; + var db = Biz.Db; var dbTran = db.UseTran(() => { db.Deleteable<BIZ_MES_WO>().Where(x => x.ID == woId).ExecuteCommand(); diff --git a/Tiger.Business.MES/MES_WORKSHOP.cs b/Tiger.Business.MES/MES_WORKSHOP.cs index faece73..7cd353e 100644 --- a/Tiger.Business.MES/MES_WORKSHOP.cs +++ b/Tiger.Business.MES/MES_WORKSHOP.cs @@ -1,7 +1,6 @@ 锘縰sing Tiger.Model; using Rhea.Common; using Tiger.IBusiness; -using static Tiger.Business.Biz; using Microsoft.AspNetCore.Http; namespace Tiger.Business.MES @@ -21,13 +20,13 @@ var result = new ApiAction(); try { - if (Db.Queryable<MES_WORKSHOP>().Where(x => x.WS_CODE == ws.WS_CODE && x.ID != ws.ID).Any()) + if (Biz.Db.Queryable<MES_WORKSHOP>().Where(x => x.WS_CODE == ws.WS_CODE && x.ID != ws.ID).Any()) { result.IsSuccessed = false; result.LocaleMsg = new($"杞﹂棿宸茬粡瀛樺湪锛屼笉鑳芥柊澧烇紒"); return result; } - var db = Db; + var db = Biz.Db; var dbTran = db.UseTran(() => { var y = db.Storageable(ws) @@ -60,7 +59,7 @@ try { //鏌ヨ鏄惁宸茬粡鏈夎溅闂村湪鐢� - var db = Db; + var db = Biz.Db; var dbTran = db.UseTran(() => { db.Deleteable<MES_WORKSHOP>().Where(x => x.ID == wsId).ExecuteCommand(); diff --git a/Tiger.Business.MES/SMT/SmtTool.cs b/Tiger.Business.MES/SMT/SmtTool.cs index fde0f94..d2383bc 100644 --- a/Tiger.Business.MES/SMT/SmtTool.cs +++ b/Tiger.Business.MES/SMT/SmtTool.cs @@ -10,7 +10,6 @@ using System.Linq; using Newtonsoft.Json; using Tiger.IBusiness; -using static Tiger.Business.Biz; using Microsoft.AspNetCore.Http; using System.Collections; using System.Data; @@ -34,7 +33,7 @@ List<SMT_WO_TABLE> sList = new List<SMT_WO_TABLE>(); try { - sList = Db.Queryable<SMT_WO_TABLE, SMT_LOADING>((t, l) => + sList = Biz.Db.Queryable<SMT_WO_TABLE, SMT_LOADING>((t, l) => new JoinQueryInfos( JoinType.Left, t.WORK_ORDER == l.WORK_ORDER @@ -112,7 +111,7 @@ item.鍘熷洜 += $"绔欎綅鍙蜂负绌猴紒"; } currentList.Add(item); - if (await Db.Queryable<SMT_WO_TABLE>().AnyAsync(x => x.WORK_ORDER == item.鍏宠仈宸ュ崟鍙� && x.ITEM_CODE == item.鐗╂枡缂栫爜 && x.SLOT_NO == item.绔欎綅鍙� && x.SMT_CODE == item.璐寸墖鏈虹紪鐮�)) + if (await Biz.Db.Queryable<SMT_WO_TABLE>().AnyAsync(x => x.WORK_ORDER == item.鍏宠仈宸ュ崟鍙� && x.ITEM_CODE == item.鐗╂枡缂栫爜 && x.SLOT_NO == item.绔欎綅鍙� && x.SMT_CODE == item.璐寸墖鏈虹紪鐮�)) { item.澶勭悊鏂瑰紡 = "淇敼"; item.鍘熷洜 += $"宸ュ崟{item.鍏宠仈宸ュ崟鍙穧锛岀墿鏂欑紪鐮亄item.鐗╂枡缂栫爜}锛岀珯浣嶅彿{item.绔欎綅鍙穧锛岃创鐗囨満缂栫爜{item.璐寸墖鏈虹紪鐮亇涓庢暟鎹簱閲嶅锛�"; diff --git a/Tiger.Business.MengQi/Mq.Customer.cs b/Tiger.Business.MengQi/Mq.Customer.cs new file mode 100644 index 0000000..f982e68 --- /dev/null +++ b/Tiger.Business.MengQi/Mq.Customer.cs @@ -0,0 +1,110 @@ +锘縰sing Rhea.Common; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tiger.IBusiness; +using Tiger.Model; + +namespace Tiger.Business.MengQi +{ + /// <summary> + /// 瀹㈡埛 + /// </summary> + public partial class MqCustomer : ICustomer + { + /// <summary> + /// 鑾峰彇鍒嗛〉 + /// </summary> + /// <param name="pageList"></param> + /// <returns></returns> + public async Task<ApiAction<PageAble<Customer>>> GetCustomers(PageAble<Customer> pageList) + { + var res = new ApiAction<PageAble<Customer>>(); + try + { + RefAsync<int> total = 0; + pageList.data = await Biz.Db.Queryable<Customer>().WhereIF(!string.IsNullOrEmpty(pageList.sqlcmd), x => x.CustomerCode.Contains(pageList.sqlcmd)).OrderBy(x => x.CustomerCode).ToPageListAsync(pageList.pageIndex, pageList.pageSize, total); + pageList.totals = total; + } + catch (Exception ex) + { + res.CatchExceptionWithLog(ex, "鑾峰彇瀹㈡埛淇℃伅寮傚父"); + } + res.Data = pageList; + return res; + } + + /// <summary> + /// 鑾峰彇瀹㈡埛淇℃伅 + /// </summary> + /// <returns></returns> + public async Task<ApiAction<List<Customer>>> GetCustomerInfo() + { + var res = new ApiAction<List<Customer>>(); + try + { + List<Customer> result = await Biz.Db.Queryable<Customer>().ToListAsync(); + res.Data = result; + } + catch (Exception ex) + { + res.CatchExceptionWithLog(ex, "鑾峰彇瀹㈡埛淇℃伅寮傚父"); + } + return res; + } + + public async Task<ApiAction> SaveImportCustomerInfo(List<Customer> list) + { + var res = new ApiAction(); + //鏇存柊瀹㈡埛璁板綍 + var db = Biz.Db; + var dbTran = await db.UseTranAsync(async () => + { + await db.Saveable(list).ExecuteCommandAsync(); + }); + if (!dbTran.IsSuccess) + { + res.IsSuccessed = false; + res.Message = $"瀵煎叆寮傚父"; + } + return res; + } + + /// <summary> + /// 淇濆瓨瀹㈡埛 + /// </summary> + /// <param name="user"></param> + /// <returns></returns> + public async Task<ApiAction> SaveCustomer(Customer customer) + { + var result = new ApiAction(); + try + { + + var db = Biz.Db; + var dbTran = db.UseTran(() => + { + var y = db.Storageable(customer) + .WhereColumns(t => new { t.CustomerCode }) + .ToStorage(); + y.AsInsertable.ExecuteCommand(); + y.AsUpdateable.ExecuteCommand(); + }); + if (!dbTran.IsSuccess) + { + result.IsSuccessed = false; + result.Message = $"瀵煎叆寮傚父"; + } + } + catch (Exception ex) + { + result.CatchExceptionWithLog(ex, "淇濆瓨瀹㈡埛寮傚父"); + } + return result; + } + } +} diff --git a/Tiger.Business.MengQi/Mq.ModelInfo.cs b/Tiger.Business.MengQi/Mq.ModelInfo.cs new file mode 100644 index 0000000..f009ea6 --- /dev/null +++ b/Tiger.Business.MengQi/Mq.ModelInfo.cs @@ -0,0 +1,96 @@ +锘縰sing Rhea.Common; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tiger.IBusiness; +using Tiger.Model; + +namespace Tiger.Business.MengQi +{ + /// <summary> + /// 瀹㈡埛 + /// </summary> + public partial class MqModelInfo : IModelInfo + { + /// <summary> + /// 鑾峰彇鍒嗛〉 + /// </summary> + /// <param name="pageList"></param> + /// <returns></returns> + public async Task<ApiAction<PageAble<ModelInfo>>> GetModelInfo(PageAble<ModelInfo> pageList) + { + var res = new ApiAction<PageAble<ModelInfo>>(); + try + { + RefAsync<int> total = 0; + pageList.data = await Biz.Db.Queryable<ModelInfo>().WhereIF(!string.IsNullOrEmpty(pageList.sqlcmd), x => x.Model.Contains(pageList.sqlcmd)).OrderBy(x => x.Model).ToPageListAsync(pageList.pageIndex, pageList.pageSize, total); + pageList.totals = total; + } + catch (Exception ex) + { + res.CatchExceptionWithLog(ex, "鑾峰彇浜у搧淇℃伅寮傚父"); + } + res.Data = pageList; + return res; + } + + /// <summary> + /// 瀵煎叆 + /// </summary> + /// <param name="list"></param> + /// <returns></returns> + public async Task<ApiAction> SaveImportModelInfo(List<ModelInfo> list) + { + var res = new ApiAction(); + //鏇存柊鏈哄瀷璁板綍 + var db = Biz.Db; + var dbTran = await db.UseTranAsync(async () => + { + await db.Saveable(list).ExecuteCommandAsync(); + }); + if (!dbTran.IsSuccess) + { + res.IsSuccessed = false; + res.Message = $"瀵煎叆寮傚父"; + } + return res; + } + + /// <summary> + /// 淇濆瓨鏈哄瀷 + /// </summary> + /// <param name="user"></param> + /// <returns></returns> + public async Task<ApiAction> SaveModel(ModelInfo modelInfo) + { + var result = new ApiAction(); + try + { + + var db = Biz.Db; + var dbTran = db.UseTran(() => + { + var y = db.Storageable(modelInfo) + .WhereColumns(t => new { t.Model }) + .ToStorage(); + y.AsInsertable.ExecuteCommand(); + y.AsUpdateable.ExecuteCommand(); + }); + if (!dbTran.IsSuccess) + { + result.IsSuccessed = false; + result.Message = $"瀵煎叆寮傚父"; + } + } + catch (Exception ex) + { + result.CatchExceptionWithLog(ex, "淇濆瓨鏈哄瀷寮傚父"); + } + return result; + } + } +} diff --git a/Tiger.Business.MengQi/Mq.SNData.cs b/Tiger.Business.MengQi/Mq.SNData.cs new file mode 100644 index 0000000..067ed5f --- /dev/null +++ b/Tiger.Business.MengQi/Mq.SNData.cs @@ -0,0 +1,202 @@ +锘縰sing Rhea.Common; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tiger.IBusiness; +using Tiger.Model; + +namespace Tiger.Business.MengQi +{ + /// <summary> + /// SN鎿嶄綔 + /// </summary> + public partial class MqSNData : IMqSNData + { + /// <summary> + /// 閫�鍥炲垹闄ゆ潯鐮� + /// </summary> + /// <param name="barcode"></param> + /// <returns></returns> + public async Task<ApiAction> ReturnSN(string barcode) + { + var result = new ApiAction(); + try + { + SNData_His data_His = await Biz.Db.Queryable<SNData_His>().Where(x => x.OriginalSN == barcode).FirstAsync(); + if (data_His == null) + { + result.IsSuccessed = false; + result.Message = $"閫�鍥炲垹闄ゆ潯鐮佷笉瀛樺湪"; + return result; + } + List<SNData> sndatas = await Biz.Db.Queryable<SNData>().Where(x => x.SN == barcode || x.SN == data_His.SN).ToListAsync(); + if (sndatas == null && sndatas.Count > 0) + { + result.IsSuccessed = false; + result.Message = $"閫�鍥炲垹闄ゆ潯鐮佷笉瀛樺湪"; + return result; + } + result.Data = data_His.DeliveryNo; + var db = Biz.Db; + var dbTran = db.UseTran(() => + { + db.Deleteable(data_His).ExecuteCommand(); + db.Deleteable(sndatas).ExecuteCommand(); + }); + if (!dbTran.IsSuccess) + { + result.IsSuccessed = false; + result.Message = $"閫�鍥炲垹闄ゆ潯鐮佸紓甯�"; + } + } + catch (Exception ex) + { + result.CatchExceptionWithLog(ex, "閫�鍥炲垹闄ゆ潯鐮佸紓甯�"); + } + return result; + } + + /// <summary> + /// 鏁村崟閫�鍥� + /// </summary> + /// <param name="deliveryNo"></param> + /// <returns></returns> + public async Task<ApiAction> ReturnWhole(string deliveryNo) + { + var result = new ApiAction(); + try + { + List<SNData_His> listHis = await Biz.Db.Queryable<SNData_His>().Where(x => x.DeliveryNo == deliveryNo).ToListAsync(); + if (listHis.Count == 0) + { + result.IsSuccessed = false; + result.Message = $"閫�鍥為�佽揣鍗昜{deliveryNo}]鏌ヤ笉鍒拌鍒犻櫎鐨勬潯鐮�"; + return result; + } + List<SNData> sndatas = await Biz.Db.Queryable<SNData>().Where(x => x.DeliveryNo == deliveryNo).ToListAsync(); + if (sndatas.Count == 0) + { + result.IsSuccessed = false; + result.Message = $"閫�鍥為�佽揣鍗昜{deliveryNo}]鏌ヤ笉鍒拌鍒犻櫎鐨勬潯鐮�"; + return result; + } + var db = Biz.Db; + var dbTran = db.UseTran(() => + { + db.Deleteable(listHis).ExecuteCommand(); + db.Deleteable(sndatas).ExecuteCommand(); + }); + if (!dbTran.IsSuccess) + { + result.IsSuccessed = false; + result.Message = $"閫�鍥炲垹闄ゆ潯鐮佸紓甯�"; + } + } + catch (Exception ex) + { + result.CatchExceptionWithLog(ex, "閫�鍥炲垹闄ゆ潯鐮佸紓甯�"); + } + return result; + } + + /// <summary> + /// 鍒嗛〉 + /// </summary> + /// <param name="pageList"></param> + /// <returns></returns> + public async Task<ApiAction<PageAble<SNData_His>>> GetSNDataHis(PageAble<SNData_His> pageList) + { + var res = new ApiAction<PageAble<SNData_His>>(); + try + { + string[] strTime = pageList.sqlcmd?.Split(','); + RefAsync<int> total = 0; + pageList.data = await Biz.Db.Queryable<SNData_His>() + .WhereIF(!string.IsNullOrEmpty(strTime[0]), x => Convert.ToDateTime(x.ScanTime) > Convert.ToDateTime(strTime[0])) + .WhereIF(!string.IsNullOrEmpty(strTime[1]) && strTime.Length == 2, x => Convert.ToDateTime(x.ScanTime) < Convert.ToDateTime(strTime[1])) + .WhereIF(!string.IsNullOrEmpty(strTime[2]), x => x.ModelCode.Equals(strTime[2])) + .WhereIF(!string.IsNullOrEmpty(strTime[3]), x => x.CustomerCode.Equals(strTime[3])) + .WhereIF(!string.IsNullOrEmpty(strTime[4]), x => x.DeliveryNo.Equals(strTime[4])) + .WhereIF(!string.IsNullOrEmpty(strTime[5]), x => x.CustModel.Equals(strTime[5])) + .ToPageListAsync(pageList.pageIndex, pageList.pageSize, total); + pageList.totals = total; + } + catch (Exception ex) + { + res.CatchExceptionWithLog(ex, "鏌ヨ寮傚父"); + } + res.Data = pageList; + return res; + } + + /// <summary> + /// 鑾峰彇鎵�鏈夋潯鐮侊紝鍘熷巶鏉$爜鍜屽鎴锋潯鐮佸湪鍚屼竴琛岋紝鎸夋潯浠� + /// </summary> + /// <param name="where"></param> + /// <returns></returns> + public async Task<ApiAction<List<SNData_His>>> GetAllSNDataHis(SNDataWhere where) + { + var res = new ApiAction<List<SNData_His>>(); + List<SNData_His> list = new List<SNData_His>(); + try + { + DateTime StartTime = DateTime.Now; + DateTime EndTime = DateTime.Now; + string[] strTime = where.strStartEnd?.Split(','); + if (!string.IsNullOrEmpty(where.strStartEnd)) { StartTime = Convert.ToDateTime(strTime[0].ToString()); EndTime = strTime.Length == 2 ? Convert.ToDateTime(strTime[1].ToString()) : DateTime.MinValue; } + RefAsync<int> total = 0; + list = await Biz.Db.Queryable<SNData_His>() + .WhereIF(!string.IsNullOrEmpty(where.strStartEnd), x => Convert.ToDateTime(x.ScanTime) > StartTime) + .WhereIF(!string.IsNullOrEmpty(where.strStartEnd) && strTime.Length == 2, x => Convert.ToDateTime(x.ScanTime) < EndTime) + .WhereIF(!string.IsNullOrEmpty(where.model), x => x.ModelCode == where.model) + .WhereIF(!string.IsNullOrEmpty(where.customerCode), x => x.CustomerCode.Equals(where.customerCode)) + .WhereIF(!string.IsNullOrEmpty(where.deliveryNo), x => x.DeliveryNo.Equals(where.deliveryNo)) + .WhereIF(!string.IsNullOrEmpty(where.custParam1), x => x.CustModel.Equals(where.custParam1)) + .ToListAsync(); + } + catch (Exception ex) + { + res.CatchExceptionWithLog(ex, "鏌ヨ寮傚父"); + } + res.Data = list; + return res; + } + + /// <summary> + /// 鑾峰彇鎵�鏈夋潯鐮侊紝鍘熷巶鏉$爜鍜屽鎴锋潯鐮佸垎寮�涓よ锛屾寜鏉′欢 + /// </summary> + /// <param name="where"></param> + /// <returns></returns> + public async Task<ApiAction<List<SNData>>> GetAllSNData(SNDataWhere where) + { + var res = new ApiAction<List<SNData>>(); + List<SNData> list = new List<SNData>(); + try + { + DateTime StartTime = DateTime.Now; + DateTime EndTime = DateTime.Now; + string[] strTime = where.strStartEnd?.Split(','); + if (!string.IsNullOrEmpty(where.strStartEnd)) { StartTime = Convert.ToDateTime(strTime[0].ToString()); EndTime = strTime.Length == 2 ? Convert.ToDateTime(strTime[1].ToString()) : DateTime.MinValue; } + RefAsync<int> total = 0; + list = await Biz.Db.Queryable<SNData>() + .WhereIF(!string.IsNullOrEmpty(where.strStartEnd), x => Convert.ToDateTime(x.CREATE_TIME) > StartTime) + .WhereIF(!string.IsNullOrEmpty(where.strStartEnd) && strTime.Length == 2, x => Convert.ToDateTime(x.CREATE_TIME) < EndTime) + .WhereIF(!string.IsNullOrEmpty(where.model), x => x.ItemCode == where.model) + .WhereIF(!string.IsNullOrEmpty(where.customerCode), x => x.CustomerCode.Equals(where.customerCode)) + .WhereIF(!string.IsNullOrEmpty(where.deliveryNo), x => x.DeliveryNo.Equals(where.deliveryNo)) + .WhereIF(!string.IsNullOrEmpty(where.custParam1), x => x.CustModel.Equals(where.custParam1)) + .OrderBy(x => x.CREATE_TIME).OrderBy(x => x.Scanner).ToListAsync(); + } + catch (Exception ex) + { + res.CatchExceptionWithLog(ex, "鏌ヨ寮傚父"); + } + res.Data = list; + return res; + } + } +} diff --git a/Tiger.Business.MengQi/Tiger.Business.MengQi.csproj b/Tiger.Business.MengQi/Tiger.Business.MengQi.csproj new file mode 100644 index 0000000..91b54bd --- /dev/null +++ b/Tiger.Business.MengQi/Tiger.Business.MengQi.csproj @@ -0,0 +1,18 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFramework>net6.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + + <Target Name="PostBuild" AfterTargets="PostBuildEvent"> + <Exec Command="xcopy /r/y/i $(ProjectDir)$(OutDir)$(AssemblyName).dll $(SolutionDir)Tiger.Api\$(OutDir)
xcopy /r/y/i $(ProjectDir)$(OutDir)$(AssemblyName).pdb $(SolutionDir)Tiger.Api\$(OutDir)
xcopy /r/y/i $(ProjectDir)$(OutDir)BizSettings.json $(SolutionDir)Tiger.Api\$(OutDir)" /> + </Target> + + <ItemGroup> + <ProjectReference Include="..\Tiger.Business\Tiger.Business.csproj" /> + <ProjectReference Include="..\Tiger.IBusiness\Tiger.IBusiness.csproj" /> + </ItemGroup> + +</Project> diff --git a/Tiger.Business.MengQi/User.cs b/Tiger.Business.MengQi/User.cs new file mode 100644 index 0000000..4b05348 --- /dev/null +++ b/Tiger.Business.MengQi/User.cs @@ -0,0 +1,140 @@ +锘縰sing Rhea.Common; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tiger.IBusiness; +using Tiger.Model; + +namespace Tiger.Business.MengQi +{ + /// <summary> + /// 鐢ㄦ埛 + /// </summary> + public partial class Users : IUser + { + /// <summary> + /// 鑾峰彇鐢ㄦ埛淇℃伅 + /// </summary> + /// <param name="pageList"></param> + /// <returns></returns> + /// <exception cref="NotImplementedException"></exception> + public async Task<PageAble<User>> GetUserInfo(PageAble<User> pageList) + { + RefAsync<int> total = 0; + pageList.data = await Biz.Db.Queryable<User>().WhereIF(!string.IsNullOrEmpty(pageList.sqlcmd), x => x.UserCode.Contains(pageList.sqlcmd)).ToPageListAsync(pageList.pageIndex, pageList.pageSize, total); + pageList.totals = total; + return pageList; + } + + /// <summary> + /// 鐢ㄦ埛鐧诲綍 + /// </summary> + /// <param name="userInfo"></param> + /// <returns></returns> + public async Task<ApiAction<User>> Login(User userInfo) + { + var res = new ApiAction<User>(); + try + { + string usercode = userInfo.UserCode; + if (userInfo.UserCode == "鍝佽川鐢ㄦ埛") + { + var user = await Biz.Db.Queryable<User>().Where(x => x.RoleCode == "鍝佽川").FirstAsync(); + if (user != null) { usercode = user.UserCode; } + } + if (!Biz.Db.Queryable<User>().Where(x => x.UserCode == usercode && x.Password == userInfo.Password).Any()) + { + //result = new(Result.Flags.Failed, "鐢ㄦ埛娌℃湁鏉冮檺鎴栬�呯敤鎴峰悕鍜屽瘑鐮侀敊璇紒"); + userInfo = new(); + } + else + { + userInfo = await Biz.Db.Queryable<User>().Where(x => x.UserCode == usercode && x.Password == userInfo.Password).FirstAsync(); + } + res.Data = userInfo; + } + catch (Exception ex) + { + res.CatchExceptionWithLog(ex, "鐧诲綍寮傚父"); + } + return res; + } + + /// <summary> + /// + /// </summary> + /// <param name="dt"></param> + /// <returns></returns> + public async Task<Result> SaveImportUserInfo(DataTable dt) + { + + Result result = new Result(Result.Flags.Success, $"瀵煎叆鎴愬姛"); + List<User> list = new(); + for (int i = 0; i < dt.Rows.Count; i++) + { + User item = new() + { + id = Guid.NewGuid().ToString("N"), + UserCode = dt.Rows[i]["鐢ㄦ埛ID"].ToString(), + UserName = dt.Rows[i]["鐢ㄦ埛鍚嶇О"].ToString(), + RoleCode = dt.Rows[i]["鐢ㄦ埛瑙掕壊"].ToString(), + }; + var info = Biz.Db.Queryable<User>().Where(x => x.UserCode == dt.Rows[i]["鐢ㄦ埛ID"].ToString()).First(); + if (info != null) + { + item.id = info.id; + } + list.Add(item); + } + //鏇存柊鏈哄瀷璁板綍 + var db = Biz.Db; + var dbTran = await db.UseTranAsync(async () => + { + await db.Saveable(list).ExecuteCommandAsync(); + }); + if (!dbTran.IsSuccess) + { + result.Flag = Result.Flags.Failed; + result.Message = $"瀵煎叆寮傚父"; + } + return result; + } + + /// <summary> + /// 淇濆瓨鐢ㄦ埛 + /// </summary> + /// <param name="user"></param> + /// <returns></returns> + public async Task<ApiAction> SaveUser(User user) + { + var result = new ApiAction(); + try + { + + var db = Biz.Db; + var dbTran = db.UseTran(() => + { + var y = db.Storageable(user) + .WhereColumns(t => new { t.UserCode }) + .ToStorage(); + y.AsInsertable.ExecuteCommand(); + y.AsUpdateable.ExecuteCommand(); + }); + if (!dbTran.IsSuccess) + { + result.IsSuccessed = false; + result.Message = $"瀵煎叆寮傚父"; + } + } + catch (Exception ex) + { + result.CatchExceptionWithLog(ex, "淇濆瓨鐢ㄦ埛寮傚父"); + } + return result; + } + } +} diff --git a/Tiger.Business/Language/LanguageEntity.cs b/Tiger.Business/Language/LanguageEntity.cs index ae70b86..b1096cd 100644 --- a/Tiger.Business/Language/LanguageEntity.cs +++ b/Tiger.Business/Language/LanguageEntity.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using static Tiger.Business.Biz; namespace Tiger.Business { diff --git a/Tiger.Business/MES/Biz.Route.cs b/Tiger.Business/MES/Biz.Route.cs index b79435d..5af0a87 100644 --- a/Tiger.Business/MES/Biz.Route.cs +++ b/Tiger.Business/MES/Biz.Route.cs @@ -10,7 +10,6 @@ using System.Linq; using Newtonsoft.Json; using Tiger.IBusiness; -using static Tiger.Business.Biz; using Microsoft.AspNetCore.Http; namespace Tiger.Business diff --git a/Tiger.Business/Tiger.Business.csproj b/Tiger.Business/Tiger.Business.csproj index 7b518a6..dc91069 100644 --- a/Tiger.Business/Tiger.Business.csproj +++ b/Tiger.Business/Tiger.Business.csproj @@ -116,6 +116,7 @@ <Folder Include="Language\TSK\" /> <Folder Include="QMS\" /> <Folder Include="RTest\" /> + <Folder Include="WMS\MengQi\" /> </ItemGroup> <ItemGroup> diff --git a/Tiger.Business/WMS/MengQi/Biz.Mq.Customer.cs b/Tiger.Business/WMS/MengQi/Biz.Mq.Customer.cs deleted file mode 100644 index 550738b..0000000 --- a/Tiger.Business/WMS/MengQi/Biz.Mq.Customer.cs +++ /dev/null @@ -1,113 +0,0 @@ -锘縰sing Rhea.Common; -using SqlSugar; -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tiger.IBusiness; -using Tiger.Model; - -namespace Tiger.Business -{ - public partial class Biz - { - /// <summary> - /// 瀹㈡埛 - /// </summary> - public partial class MqCustomer : ICustomer - { - /// <summary> - /// 鑾峰彇鍒嗛〉 - /// </summary> - /// <param name="pageList"></param> - /// <returns></returns> - public async Task<ApiAction<PageAble<Customer>>> GetCustomers(PageAble<Customer> pageList) - { - var res = new ApiAction<PageAble<Customer>>(); - try - { - RefAsync<int> total = 0; - pageList.data = await Db.Queryable<Customer>().WhereIF(!string.IsNullOrEmpty(pageList.sqlcmd), x => x.CustomerCode.Contains(pageList.sqlcmd)).OrderBy(x=>x.CustomerCode).ToPageListAsync(pageList.pageIndex, pageList.pageSize, total); - pageList.totals = total; - } - catch (Exception ex) - { - res.CatchExceptionWithLog(ex, "鑾峰彇瀹㈡埛淇℃伅寮傚父"); - } - res.Data = pageList; - return res; - } - - /// <summary> - /// 鑾峰彇瀹㈡埛淇℃伅 - /// </summary> - /// <returns></returns> - public async Task<ApiAction<List<Customer>>> GetCustomerInfo() - { - var res = new ApiAction<List<Customer>>(); - try - { - List<Customer> result = await Db.Queryable<Customer>().ToListAsync(); - res.Data = result; - } - catch (Exception ex) - { - res.CatchExceptionWithLog(ex, "鑾峰彇瀹㈡埛淇℃伅寮傚父"); - } - return res; - } - - public async Task<ApiAction> SaveImportCustomerInfo(List<Customer> list) - { - var res = new ApiAction(); - //鏇存柊瀹㈡埛璁板綍 - var db = Db; - var dbTran = await db.UseTranAsync(async () => - { - await db.Saveable(list).ExecuteCommandAsync(); - }); - if (!dbTran.IsSuccess) - { - res.IsSuccessed = false; - res.Message = $"瀵煎叆寮傚父"; - } - return res; - } - - /// <summary> - /// 淇濆瓨瀹㈡埛 - /// </summary> - /// <param name="user"></param> - /// <returns></returns> - public async Task<ApiAction> SaveCustomer(Customer customer) - { - var result = new ApiAction(); - try - { - - var db = Db; - var dbTran = db.UseTran(() => - { - var y = db.Storageable(customer) - .WhereColumns(t => new { t.CustomerCode }) - .ToStorage(); - y.AsInsertable.ExecuteCommand(); - y.AsUpdateable.ExecuteCommand(); - }); - if (!dbTran.IsSuccess) - { - result.IsSuccessed = false; - result.Message = $"瀵煎叆寮傚父"; - } - } - catch (Exception ex) - { - result.CatchExceptionWithLog(ex, "淇濆瓨瀹㈡埛寮傚父"); - } - return result; - } - } - } -} diff --git a/Tiger.Business/WMS/MengQi/Biz.Mq.ModelInfo.cs b/Tiger.Business/WMS/MengQi/Biz.Mq.ModelInfo.cs deleted file mode 100644 index bd4fc98..0000000 --- a/Tiger.Business/WMS/MengQi/Biz.Mq.ModelInfo.cs +++ /dev/null @@ -1,99 +0,0 @@ -锘縰sing Rhea.Common; -using SqlSugar; -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tiger.IBusiness; -using Tiger.Model; - -namespace Tiger.Business -{ - public partial class Biz - { - /// <summary> - /// 瀹㈡埛 - /// </summary> - public partial class MqModelInfo : IModelInfo - { - /// <summary> - /// 鑾峰彇鍒嗛〉 - /// </summary> - /// <param name="pageList"></param> - /// <returns></returns> - public async Task<ApiAction<PageAble<ModelInfo>>> GetModelInfo(PageAble<ModelInfo> pageList) - { - var res = new ApiAction<PageAble<ModelInfo>>(); - try - { - RefAsync<int> total = 0; - pageList.data = await Db.Queryable<ModelInfo>().WhereIF(!string.IsNullOrEmpty(pageList.sqlcmd), x => x.Model.Contains(pageList.sqlcmd)).OrderBy(x=>x.Model).ToPageListAsync(pageList.pageIndex, pageList.pageSize, total); - pageList.totals = total; - } - catch (Exception ex) - { - res.CatchExceptionWithLog(ex, "鑾峰彇浜у搧淇℃伅寮傚父"); - } - res.Data = pageList; - return res; - } - - /// <summary> - /// 瀵煎叆 - /// </summary> - /// <param name="list"></param> - /// <returns></returns> - public async Task<ApiAction> SaveImportModelInfo(List<ModelInfo> list) - { - var res = new ApiAction(); - //鏇存柊鏈哄瀷璁板綍 - var db = Db; - var dbTran = await db.UseTranAsync(async () => - { - await db.Saveable(list).ExecuteCommandAsync(); - }); - if (!dbTran.IsSuccess) - { - res.IsSuccessed = false; - res.Message = $"瀵煎叆寮傚父"; - } - return res; - } - - /// <summary> - /// 淇濆瓨鏈哄瀷 - /// </summary> - /// <param name="user"></param> - /// <returns></returns> - public async Task<ApiAction> SaveModel(ModelInfo modelInfo) - { - var result = new ApiAction(); - try - { - - var db = Db; - var dbTran = db.UseTran(() => - { - var y = db.Storageable(modelInfo) - .WhereColumns(t => new { t.Model }) - .ToStorage(); - y.AsInsertable.ExecuteCommand(); - y.AsUpdateable.ExecuteCommand(); - }); - if (!dbTran.IsSuccess) - { - result.IsSuccessed = false; - result.Message = $"瀵煎叆寮傚父"; - } - } - catch (Exception ex) - { - result.CatchExceptionWithLog(ex, "淇濆瓨鏈哄瀷寮傚父"); - } - return result; - } - } - } -} diff --git a/Tiger.Business/WMS/MengQi/Biz.Mq.SNData.cs b/Tiger.Business/WMS/MengQi/Biz.Mq.SNData.cs deleted file mode 100644 index 1d63e76..0000000 --- a/Tiger.Business/WMS/MengQi/Biz.Mq.SNData.cs +++ /dev/null @@ -1,206 +0,0 @@ -锘縰sing Rhea.Common; -using SqlSugar; -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tiger.IBusiness; -using Tiger.Model; -using static Tiger.Business.Biz; - -namespace Tiger.Business -{ - public partial class Biz - { - /// <summary> - /// SN鎿嶄綔 - /// </summary> - public partial class MqSNData : IMqSNData - { - /// <summary> - /// 閫�鍥炲垹闄ゆ潯鐮� - /// </summary> - /// <param name="barcode"></param> - /// <returns></returns> - public async Task<ApiAction> ReturnSN(string barcode) - { - var result = new ApiAction(); - try - { - SNData_His data_His = await Db.Queryable<SNData_His>().Where(x => x.OriginalSN == barcode).FirstAsync(); - if (data_His == null) - { - result.IsSuccessed = false; - result.Message = $"閫�鍥炲垹闄ゆ潯鐮佷笉瀛樺湪"; - return result; - } - List<SNData> sndatas = await Db.Queryable<SNData>().Where(x => x.SN == barcode || x.SN == data_His.SN).ToListAsync(); - if (sndatas == null && sndatas.Count>0) - { - result.IsSuccessed = false; - result.Message = $"閫�鍥炲垹闄ゆ潯鐮佷笉瀛樺湪"; - return result; - } - result.Data = data_His.DeliveryNo; - var db = Db; - var dbTran = db.UseTran(() => - { - db.Deleteable(data_His).ExecuteCommand(); - db.Deleteable(sndatas).ExecuteCommand(); - }); - if (!dbTran.IsSuccess) - { - result.IsSuccessed = false; - result.Message = $"閫�鍥炲垹闄ゆ潯鐮佸紓甯�"; - } - } - catch (Exception ex) - { - result.CatchExceptionWithLog(ex, "閫�鍥炲垹闄ゆ潯鐮佸紓甯�"); - } - return result; - } - - /// <summary> - /// 鏁村崟閫�鍥� - /// </summary> - /// <param name="deliveryNo"></param> - /// <returns></returns> - public async Task<ApiAction> ReturnWhole(string deliveryNo) - { - var result = new ApiAction(); - try - { - List<SNData_His> listHis = await Db.Queryable<SNData_His>().Where(x => x.DeliveryNo == deliveryNo).ToListAsync(); - if (listHis.Count == 0) - { - result.IsSuccessed = false; - result.Message = $"閫�鍥為�佽揣鍗昜{deliveryNo}]鏌ヤ笉鍒拌鍒犻櫎鐨勬潯鐮�"; - return result; - } - List<SNData> sndatas = await Db.Queryable<SNData>().Where(x => x.DeliveryNo == deliveryNo).ToListAsync(); - if (sndatas.Count == 0) - { - result.IsSuccessed = false; - result.Message = $"閫�鍥為�佽揣鍗昜{deliveryNo}]鏌ヤ笉鍒拌鍒犻櫎鐨勬潯鐮�"; - return result; - } - var db = Db; - var dbTran = db.UseTran(() => - { - db.Deleteable(listHis).ExecuteCommand(); - db.Deleteable(sndatas).ExecuteCommand(); - }); - if (!dbTran.IsSuccess) - { - result.IsSuccessed = false; - result.Message = $"閫�鍥炲垹闄ゆ潯鐮佸紓甯�"; - } - } - catch (Exception ex) - { - result.CatchExceptionWithLog(ex, "閫�鍥炲垹闄ゆ潯鐮佸紓甯�"); - } - return result; - } - - /// <summary> - /// 鍒嗛〉 - /// </summary> - /// <param name="pageList"></param> - /// <returns></returns> - public async Task<ApiAction<PageAble<SNData_His>>> GetSNDataHis(PageAble<SNData_His> pageList) - { - var res = new ApiAction<PageAble<SNData_His>>(); - try - { - string[] strTime = pageList.sqlcmd?.Split(','); - RefAsync<int> total = 0; - pageList.data = await Db.Queryable<SNData_His>() - .WhereIF(!string.IsNullOrEmpty(strTime[0]), x => Convert.ToDateTime(x.ScanTime) > Convert.ToDateTime(strTime[0])) - .WhereIF(!string.IsNullOrEmpty(strTime[1]) && strTime.Length == 2, x => Convert.ToDateTime(x.ScanTime) < Convert.ToDateTime(strTime[1])) - .WhereIF(!string.IsNullOrEmpty(strTime[2]), x => x.ModelCode.Equals(strTime[2])) - .WhereIF(!string.IsNullOrEmpty(strTime[3]), x => x.CustomerCode.Equals(strTime[3])) - .WhereIF(!string.IsNullOrEmpty(strTime[4]), x => x.DeliveryNo.Equals(strTime[4])) - .WhereIF(!string.IsNullOrEmpty(strTime[5]), x => x.CustModel.Equals(strTime[5])) - .ToPageListAsync(pageList.pageIndex, pageList.pageSize, total); - pageList.totals = total; - } - catch (Exception ex) - { - res.CatchExceptionWithLog(ex, "鏌ヨ寮傚父"); - } - res.Data = pageList; - return res; - } - - /// <summary> - /// 鑾峰彇鎵�鏈夋潯鐮侊紝鍘熷巶鏉$爜鍜屽鎴锋潯鐮佸湪鍚屼竴琛岋紝鎸夋潯浠� - /// </summary> - /// <param name="where"></param> - /// <returns></returns> - public async Task<ApiAction<List<SNData_His>>> GetAllSNDataHis(SNDataWhere where) - { - var res = new ApiAction<List<SNData_His>>(); - List<SNData_His> list = new List<SNData_His>(); - try - { - DateTime StartTime = DateTime.Now; - DateTime EndTime = DateTime.Now; - string[] strTime = where.strStartEnd?.Split(','); - if (!string.IsNullOrEmpty(where.strStartEnd)) { StartTime = Convert.ToDateTime(strTime[0].ToString()); EndTime = strTime.Length == 2 ? Convert.ToDateTime(strTime[1].ToString()) : DateTime.MinValue; } - RefAsync<int> total = 0; - list = await Db.Queryable<SNData_His>() - .WhereIF(!string.IsNullOrEmpty(where.strStartEnd), x => Convert.ToDateTime(x.ScanTime) > StartTime) - .WhereIF(!string.IsNullOrEmpty(where.strStartEnd) && strTime.Length == 2, x => Convert.ToDateTime(x.ScanTime) < EndTime) - .WhereIF(!string.IsNullOrEmpty(where.model), x => x.ModelCode == where.model) - .WhereIF(!string.IsNullOrEmpty(where.customerCode), x => x.CustomerCode.Equals(where.customerCode)) - .WhereIF(!string.IsNullOrEmpty(where.deliveryNo), x => x.DeliveryNo.Equals(where.deliveryNo)) - .WhereIF(!string.IsNullOrEmpty(where.custParam1), x => x.CustModel.Equals(where.custParam1)) - .ToListAsync(); - } - catch (Exception ex) - { - res.CatchExceptionWithLog(ex, "鏌ヨ寮傚父"); - } - res.Data = list; - return res; - } - - /// <summary> - /// 鑾峰彇鎵�鏈夋潯鐮侊紝鍘熷巶鏉$爜鍜屽鎴锋潯鐮佸垎寮�涓よ锛屾寜鏉′欢 - /// </summary> - /// <param name="where"></param> - /// <returns></returns> - public async Task<ApiAction<List<SNData>>> GetAllSNData(SNDataWhere where) - { - var res = new ApiAction<List<SNData>>(); - List<SNData> list = new List<SNData>(); - try - { - DateTime StartTime = DateTime.Now; - DateTime EndTime = DateTime.Now; - string[] strTime = where.strStartEnd?.Split(','); - if (!string.IsNullOrEmpty(where.strStartEnd)) { StartTime = Convert.ToDateTime(strTime[0].ToString()); EndTime = strTime.Length == 2 ? Convert.ToDateTime(strTime[1].ToString()) : DateTime.MinValue; } - RefAsync<int> total = 0; - list = await Db.Queryable<SNData>() - .WhereIF(!string.IsNullOrEmpty(where.strStartEnd), x => Convert.ToDateTime(x.CREATE_TIME) > StartTime) - .WhereIF(!string.IsNullOrEmpty(where.strStartEnd) && strTime.Length == 2, x => Convert.ToDateTime(x.CREATE_TIME) < EndTime) - .WhereIF(!string.IsNullOrEmpty(where.model), x => x.ItemCode == where.model) - .WhereIF(!string.IsNullOrEmpty(where.customerCode), x => x.CustomerCode.Equals(where.customerCode)) - .WhereIF(!string.IsNullOrEmpty(where.deliveryNo), x => x.DeliveryNo.Equals(where.deliveryNo)) - .WhereIF(!string.IsNullOrEmpty(where.custParam1), x => x.CustModel.Equals(where.custParam1)) - .OrderBy(x=>x.CREATE_TIME).OrderBy(x => x.Scanner).ToListAsync(); - } - catch (Exception ex) - { - res.CatchExceptionWithLog(ex, "鏌ヨ寮傚父"); - } - res.Data = list; - return res; - } - } - } -} diff --git a/Tiger.Business/WMS/MengQi/Biz.User.cs b/Tiger.Business/WMS/MengQi/Biz.User.cs deleted file mode 100644 index 44b4560..0000000 --- a/Tiger.Business/WMS/MengQi/Biz.User.cs +++ /dev/null @@ -1,142 +0,0 @@ -锘縰sing Rhea.Common; -using SqlSugar; -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tiger.IBusiness; -using Tiger.Model; - -namespace Tiger.Business -{ - public partial class Biz - { - /// <summary> - /// 鐢ㄦ埛 - /// </summary> - public partial class Users : IUser - { - /// <summary> - /// 鑾峰彇鐢ㄦ埛淇℃伅 - /// </summary> - /// <param name="pageList"></param> - /// <returns></returns> - /// <exception cref="NotImplementedException"></exception> - public async Task<PageAble<User>> GetUserInfo(PageAble<User> pageList) - { - RefAsync<int> total = 0; - pageList.data = await Db.Queryable<User>().WhereIF(!string.IsNullOrEmpty(pageList.sqlcmd), x => x.UserCode.Contains(pageList.sqlcmd)).ToPageListAsync(pageList.pageIndex, pageList.pageSize, total); - pageList.totals = total; - return pageList; - } - - /// <summary> - /// 鐢ㄦ埛鐧诲綍 - /// </summary> - /// <param name="userInfo"></param> - /// <returns></returns> - public async Task<ApiAction<User>> Login(User userInfo) - { - var res = new ApiAction<User>(); - try - { - string usercode = userInfo.UserCode; - if (userInfo.UserCode == "鍝佽川鐢ㄦ埛") - { - var user = await Db.Queryable<User>().Where(x => x.RoleCode == "鍝佽川").FirstAsync(); - if (user != null) { usercode = user.UserCode; } - } - if (!Db.Queryable<User>().Where(x => x.UserCode == usercode && x.Password == userInfo.Password).Any()) - { - //result = new(Result.Flags.Failed, "鐢ㄦ埛娌℃湁鏉冮檺鎴栬�呯敤鎴峰悕鍜屽瘑鐮侀敊璇紒"); - userInfo = new(); - } - else - { - userInfo = await Db.Queryable<User>().Where(x => x.UserCode == usercode && x.Password == userInfo.Password).FirstAsync(); - } - res.Data = userInfo; - } - catch (Exception ex) - { - res.CatchExceptionWithLog(ex, "鐧诲綍寮傚父"); - } - return res; - } - - /// <summary> - /// - /// </summary> - /// <param name="dt"></param> - /// <returns></returns> - public async Task<Result> SaveImportUserInfo(DataTable dt) - { - - Result result = new Result(Result.Flags.Success, $"瀵煎叆鎴愬姛"); - List<User> list = new(); - for (int i = 0; i < dt.Rows.Count; i++) - { - User item = new() - { - id = Guid.NewGuid().ToString("N"), - UserCode = dt.Rows[i]["鐢ㄦ埛ID"].ToString(), - UserName = dt.Rows[i]["鐢ㄦ埛鍚嶇О"].ToString(), - RoleCode = dt.Rows[i]["鐢ㄦ埛瑙掕壊"].ToString(), - }; - var info = Db.Queryable<User>().Where(x => x.UserCode == dt.Rows[i]["鐢ㄦ埛ID"].ToString()).First(); - if (info != null) - { - item.id = info.id; - } - list.Add(item); - } - //鏇存柊鏈哄瀷璁板綍 - var db = Db; - var dbTran = await db.UseTranAsync(async () => - { - await db.Saveable(list).ExecuteCommandAsync(); - }); - if (!dbTran.IsSuccess) - { - result.Flag = Result.Flags.Failed; - result.Message = $"瀵煎叆寮傚父"; - } - return result; - } - - /// <summary> - /// 淇濆瓨鐢ㄦ埛 - /// </summary> - /// <param name="user"></param> - /// <returns></returns> - public async Task<ApiAction> SaveUser(User user) { - var result = new ApiAction(); - try - { - - var db = Db; - var dbTran = db.UseTran(() => - { - var y = db.Storageable(user) - .WhereColumns(t => new { t.UserCode }) - .ToStorage(); - y.AsInsertable.ExecuteCommand(); - y.AsUpdateable.ExecuteCommand(); - }); - if (!dbTran.IsSuccess) - { - result.IsSuccessed = false; - result.Message = $"瀵煎叆寮傚父"; - } - } - catch (Exception ex) - { - result.CatchExceptionWithLog(ex, "淇濆瓨鐢ㄦ埛寮傚父"); - } - return result; - } - } - } -} -- Gitblit v1.9.3