| | |
| | | using System.Net; |
| | | using System.Reflection; |
| | | using Swifter.Tools; |
| | | using Tiger.Model.Entitys.MES.Position; |
| | | using Microsoft.CodeAnalysis.Options; |
| | | using System.IO; |
| | | using System.Runtime.Loader; |
| | | |
| | | namespace Tiger.Api.Controllers.Test |
| | | { |
| | |
| | | public async Task<IActionResult> GetAsync(string param) |
| | | { |
| | | //var data = await Biz.Db.Queryable<SYS_PARAM>().Where(q => q.PARAM_CODE == param).FirstAsync(); |
| | | //var data = Biz.SysParam["Blue"]; |
| | | //var data = Biz.SysParam.Groups; |
| | | //var data = Biz.CodeRule["X0001"]; |
| | | //var data = Cache.SysParam["Blue"]; |
| | | //var data = Cache.SysParam.Groups; |
| | | //var data = Cache.CodeRule["X0001"]; |
| | | //取号测试 |
| | | //var data = Biz.Db.Queryable<BAS_CODE_RULE>().Where(q => q.RULE_CODE == "X0001").IncludesAllFirstLayer().First(); |
| | | //var key = string.Join("|", data.Details.Where(q => q.DATA_TYPE == BAS_CODE_DTL.DATA_TYPEs.DbCheck.GetValue()).Select(q => q.GenerateValue)); |
| | |
| | | // try |
| | | // { |
| | | // var dtl = data.Details.First(q => q.RULE_SEQ == 6); |
| | | // var sn = Biz.CodeRule.FetchSerialNo(key, dtl, index.ToString(), false); |
| | | // var sn = Cache.CodeRule.FetchSerialNo(key, dtl, index.ToString(), false); |
| | | // Console.WriteLine($"{index}: {DateTime.Now:HH:mm:ss.fff} > 取号完成[{sn}]"); |
| | | // } |
| | | // catch (Exception ex) |
| | |
| | | // } |
| | | // }); |
| | | //} |
| | | //var data = Biz.CodeRule["X0001"].Generate("PDFG", 5); |
| | | //var data1 = Biz.CodeRule["X0001"].TryGenerate("PDFG", 6); |
| | | //var data = Cache.CodeRule["X0001"].Generate("PDFG", 5); |
| | | //var data1 = Cache.CodeRule["X0001"].TryGenerate("PDFG", 6); |
| | | //条码规则验证 |
| | | //Expression<Func<BAS_CODE_RULE, bool>> predicate = q => true; |
| | | ////predicate = predicate.And(q => q.RULE_CODE == "X0002" || q.RULE_CODE == "X0001"); |
| | | //predicate = predicate.And(q => q.RULE_TYPE == 0); |
| | | ////var data = Biz.CodeRule.Rules.Where(predicate.Compile()); |
| | | //var data = Biz.CodeRule.Verify("AB23#7930000002010", predicate.Compile()); |
| | | ////var data = Cache.CodeRule.Rules.Where(predicate.Compile()); |
| | | //var data = Cache.CodeRule.Verify("AB23#7930000002010", predicate.Compile()); |
| | | return Ok(""); |
| | | } |
| | | |
| | |
| | | [HttpGet] |
| | | public async Task<IActionResult> Get2Async(string param) |
| | | { |
| | | //var auth = new AuthOption() { UserId = "admin", ByOrg = true, ByWh = true }; |
| | | var auth = new AuthOption() { UserId = "admin", ByOrg = true, ByWh = true }; |
| | | //var data = await Biz.Db.Queryable<BIZ_ERP_PO>().Where(q => q.BILLTYPE == 11) |
| | | // //.ByAuth("admin", DbAuth.Org | DbAuth.Wh) |
| | | // .ByAuth(auth) |
| | | // .ToListAsync(); |
| | | //data = await Biz.Db.Queryable<BIZ_ERP_PO>().ByAuth("admin", DbAuth.Org).Where(q => q.BILLTYPE == 11).ToListAsync(); |
| | | var data = await Biz.Db.Queryable<BIZ_ERP_PO>().Where(q => q.BILLTYPE == 11).ToListAsync(); |
| | | //var data = await Biz.Db.Queryable<BIZ_ERP_PO>().Where(q => q.BILLTYPE == 11).ToListAsync(); |
| | | //var dtl = await Biz.Db.Queryable<BIZ_ERP_PO_DTL>().ByAuth("admin", DbAuth.Org | DbAuth.Wh).Where(q => q.BILLCODE == "AH3301-221000108").ToListAsync(); |
| | | var query = Biz.Db.Queryable<WMS_ITEM_PKG>().ByAuth("admin", DbAuth.Org | DbAuth.Wh).Where(t => t.SN == "barcode.SN").First();// |
| | | var data = Biz.Db.Queryable<BIZ_MES_WO_BATCH, BIZ_MES_WO_SN>((q, s) => new JoinQueryInfos(JoinType.Inner, q.ORDER_NO == s.WORK_ORDER)) |
| | | .ByAuth(auth)//.ByAuth("admin", DbAuth.Org | DbAuth.Wh) |
| | | .Where((q, s) => s.SN == "input.SN" && q.ACT_LINE == "CurLine.LINE_CODE" && (q.STATUS == BIZ_MES_WO_BATCH.STATUSs.Release.GetValue() || q.STATUS == BIZ_MES_WO_BATCH.STATUSs.Working.GetValue())) |
| | | .Select((q, s) => new { Batch = q, SN = s }).First(); |
| | | return Ok(data); |
| | | } |
| | | |
| | |
| | | //Biz.Db.Insertable(data, "Interface").ExecuteCommand(); |
| | | |
| | | var root = new SugarParameter("root", "system01"); |
| | | var dt = Biz.Db.Ado.UseStoredProcedure().GetDataTable("PKG_SYS_GET_MENU", root);//返回dt |
| | | var data = Biz.Db.Ado.UseStoredProcedure().SqlQuery<SYS_MENU>("PKG_SYS_GET_MENU", root);//返回List |
| | | var dt = Biz.Db.Ado.UseStoredProcedure().GetDataTable("SP_SYS_GET_MENU", root);//返回dt |
| | | var data = Biz.Db.Ado.UseStoredProcedure().SqlQuery<SYS_MENU>("SP_SYS_GET_MENU", root);//返回List |
| | | ; |
| | | //var data = Biz.Db.Queryable<BIZ_SRM_DLVY>() |
| | | // .IncludesAllFirstLayer() |
| | |
| | | //{ |
| | | // throw dbTran.ErrorException; |
| | | //} |
| | | return Ok(""); |
| | | return Ok(data); |
| | | } |
| | | /// <summary> |
| | | /// |
| | |
| | | [HttpGet] |
| | | public async Task<IActionResult> D1Async(string param) |
| | | { |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=01"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 01 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=02"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 02 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=03"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 03 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=04"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 04 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=05"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 05 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=06"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 06 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=07"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 07 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=08"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 08 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=09"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 09 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=10"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 10 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=11"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 11 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=12"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 12 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=13"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 13 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=14"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 14 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=15"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 15 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=16"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 16 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=17"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 17 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=18"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 18 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=19"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 19 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=20"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 20 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=21"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 21 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=22"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 22 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=23"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 23 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=24"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 24 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=25"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 25 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=26"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 26 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=27"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 27 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=28"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 28 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=29"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 29 Finished", ConsoleColor.Blue); }); |
| | | Work.DoAsync(() => { HttpHelper.GetAsync("http://172.16.80.40:9529/api/_Test/DoSomething?duration=10&code=30"); ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - 30 Finished", ConsoleColor.Blue); }); |
| | | ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss.fff} - Send Finished", ConsoleColor.Blue); |
| | | //Logger.Scheduler.Info("这是一次成功的测试"); |
| | | //var data = iBiz.Biz.Db.Queryable<BAS_CODE_RULE>() |
| | | // .IncludesAllFirstLayer() |
| | |
| | | public partial class _TestController : ControllerBase |
| | | { |
| | | [HttpGet] |
| | | public async Task<IActionResult> DoSomething(int duration) |
| | | public async Task<IActionResult> DoSomething(int duration, string code) |
| | | { |
| | | var begin = DateTime.Now; |
| | | while ((DateTime.Now - begin).TotalSeconds <= duration) |
| | | { |
| | | Thread.Sleep(1000); |
| | | var total = (DateTime.Now - begin).TotalSeconds; |
| | | var percent = total / duration; |
| | | ConsoleExt.WriteLine($"Working {begin:mmssfff} ... {(percent > 1 ? 1 : percent):P0} ...", ConsoleColor.Green); |
| | | } |
| | | Logger.Default.Info($"{begin:mmssfff} completed"); |
| | | return Ok($"{begin:mmssfff} completed"); |
| | | Work.Do(() => { |
| | | while ((DateTime.Now - begin).TotalSeconds <= duration) |
| | | { |
| | | //Thread.Sleep(1000); |
| | | var total = (DateTime.Now - begin).TotalSeconds; |
| | | var percent = total / duration; |
| | | //ConsoleExt.WriteLine($"Working {begin:mmssfff} ... {(percent > 1 ? 1 : percent):P0} ...", ConsoleColor.Green); |
| | | } |
| | | Logger.Default.Info($"{begin:mmssfff} completed"); |
| | | }); |
| | | return Ok($"{code.IsNullOrEmpty("", code + ": ")}{begin:mmssfff} completed"); |
| | | } |
| | | |
| | | [HttpPost] |
| | | public async Task<IActionResult> MESSubmitAsync([FromBody] ApiAction<SubmitInput> action) |
| | | { |
| | | var data = action.Data.Data; |
| | | |
| | | var act = Biz.Db.Queryable<MES_WO_ACTION>().First(q => q.ID == data); |
| | | |
| | | |
| | | var result = act.OPTION_1?.ToString().JsonToObject<List<WipPkgItem>>(); |
| | | |
| | | return Ok(result?.ToJson()); |
| | | } |
| | | |
| | | [HttpPost] |
| | | public async Task<IActionResult> InterfaceAsync([FromBody] ApiAction action) |
| | | { |
| | | var data = action.Data; |
| | | |
| | | var json = new { |
| | | SN = "V025720241120000161", |
| | | ItemCode = "160305330", |
| | | Qty = 1700, |
| | | Unit = "PCS", |
| | | Supplier = "V0381", |
| | | DeliveryDate = DateTime.Now, |
| | | ProdDate = DateTime.Now, |
| | | BatchNo = "20241120", |
| | | ValidityDays = 365, |
| | | SerialNo = 161, |
| | | ItemName = "L-CW1323GA 两个装彩盒 隔板 材质300g单粉裱YF加强过哑膜 105 mm 85 mm 3 mm 南泰 ", |
| | | Warehouse = "W0001", |
| | | ItemModel = "材料 零件 商品", |
| | | }; |
| | | |
| | | var result = action.GetResponse("GetSnInfo success.", json, true); |
| | | |
| | | return Ok(new { result.Timestamp, result.IsSuccessed, result.Message, result.Data }); |
| | | } |
| | | |
| | | [HttpGet] |
| | | public async Task<IActionResult> RefreashPlugin(string path) |
| | | { |
| | | var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.GetName().Name == "Tiger.Business.MES"); |
| | | // 查找指定名称的程序集 |
| | | //var assembly = Array.Find(assemblies, a => a.GetName().Name == "Tiger.Business.MES"); |
| | | |
| | | //var ass = Assembly.LoadFrom(AppDomain.CurrentDomain.BaseDirectory + "\\Tiger.Business.MES1.dll"); |
| | | |
| | | |
| | | var mes1 = new AssemblyLoadContext("mes1", true); |
| | | var assembly1 = mes1.LoadFromAssemblyPath(AppDomain.CurrentDomain.BaseDirectory + "\\Tiger.Business1.MES.dll"); |
| | | mes1.Unloading += context => { Console.WriteLine($"当前卸载{context.Name}程序集:" + string.Join(',', context.Assemblies.Select(x => x.FullName))); }; |
| | | assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.GetName().Name == "Tiger.Business.MES"); |
| | | |
| | | var mes2 = new AssemblyLoadContext("mes2", true); |
| | | var assembly2 = mes2.LoadFromAssemblyPath(AppDomain.CurrentDomain.BaseDirectory + "\\Tiger.Business2.MES.dll"); |
| | | mes2.Unloading += context => { Console.WriteLine($"当前卸载{context.Name}程序集:" + string.Join(',', context.Assemblies.Select(x => x.FullName))); }; |
| | | assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.GetName().Name == "Tiger.Business.MES"); |
| | | |
| | | mes1.Unload(); |
| | | assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.GetName().Name == "Tiger.Business.MES"); |
| | | mes2.Unload(); |
| | | assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => a.GetName().Name == "Tiger.Business.MES"); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //var newBuilder = new ContainerBuilder(); |
| | | |
| | | ////AutoFac 配置文件注入 |
| | | //AutoFacContainer.Init(newBuilder); |
| | | //newBuilder.RegisterBuildCallback(scope => |
| | | //{ |
| | | |
| | | // AutoFacContainer.Instance = (IContainer)scope; |
| | | //}); |
| | | //var newContainer = newBuilder.Build(); |
| | | //var trans = AutoFacContainer.Instance.Resolve<ITestNode>().Init("action.ID", "Request.Host.Value", "action.Data?.USER_CODE", "OQC001"); |
| | | //var d = trans.GetDefects(); |
| | | return Ok($""); |
| | | } |
| | | } |
| | | |