From 864e17cedabba5052ee78efd19746a0309eddb93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=95=8F=E5=81=A5=20=E9=82=B1?= Date: Tue, 2 Sep 2025 22:42:09 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=AE=8C=E6=88=90=E9=94=80=E5=94=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=A8=A1=E5=9D=97=202.=E4=BF=AE=E5=A4=8D=E6=A1=A3?= =?UTF-8?q?=E6=A1=88=E6=9F=A5=E8=AF=A2=E4=B8=8E=E6=96=B0=E5=A2=9E=E5=8D=95?= =?UTF-8?q?=E6=8D=AE=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SA/ClsVoucherCO_SA.cs | 53 +- UFIDA.U8.Framework.Api/App_Data/U8API.xml | 46 +- .../App_Data/发货单模板.json | 57 + .../App_Data/销售发票模板.json | 3 +- .../Controllers/U8/AAController.cs | 1410 ++--------------- .../Controllers/U8/MOController.cs | 399 ++--- .../Controllers/U8/PUController.cs | 39 +- .../Controllers/U8/SAController.cs | 277 ++++ .../UFIDA.U8.Framework.Api.csproj | 1 + 9 files changed, 714 insertions(+), 1571 deletions(-) create mode 100644 UFIDA.U8.Framework.Api/App_Data/发货单模板.json diff --git a/UFIDA.U8.Framework.Api.ControlObject/SA/ClsVoucherCO_SA.cs b/UFIDA.U8.Framework.Api.ControlObject/SA/ClsVoucherCO_SA.cs index 6569ff9..d609760 100644 --- a/UFIDA.U8.Framework.Api.ControlObject/SA/ClsVoucherCO_SA.cs +++ b/UFIDA.U8.Framework.Api.ControlObject/SA/ClsVoucherCO_SA.cs @@ -27,17 +27,28 @@ namespace UFIDA.U8.Framework.Api.ControlObject.SA { var errorMsg = ""; - dynamic objr = new object(); - var aaa = ""; + var oSystem = "USSAServer.clsSystem".GetComObject(); + + if (!oSystem.Init(login._vbLogin, ref errorMsg)) + { + throw new Exception($"初始化失败:{errorMsg}"); + } var co = "VoucherCO_Sa.ClsVoucherCO_SA".GetComObject(); - co.Init(enmVoucherType: enmVoucherType, oLogin: ref login._vbLogin, oConn: ref login.Connection); + try + { + co.Init(enmVoucherType: enmVoucherType, oLogin: ref login._vbLogin, oConn: ref login.Connection, sysObj: oSystem); + } + catch (Exception ex) + { + throw new Exception($"初始化失败:{ex.Message}"); + } return co; } - public async Task> Save(BaseLogin baseLogin, Dictionary dictionary, string cardNumber, VoucherTypeSA enmVoucherType,int VoucherState=0, bool bGetCode = false, string codeKey = null, bool bAudit = false, bool iswfcontrolled = false, string cFlowFieldName = "IsWfControlled") + public async Task> Save(BaseLogin baseLogin, Dictionary dictionary, string cardNumber, VoucherTypeSA enmVoucherType, int VoucherState = 0, bool bGetCode = false, string codeKey = null, bool bAudit = false, bool iswfcontrolled = false, string cFlowFieldName = "IsWfControlled") { try { @@ -102,15 +113,10 @@ namespace UFIDA.U8.Framework.Api.ControlObject.SA var res = new BaseResult(); - baseLogin.Connection.BeginTrans(); - - try - { _logInfo.Debug("开始保存..."); - errorMsg = co.Save(ref domHead, ref domBody, VoucherState, ref vouchId,ref domCur); - + errorMsg = co.Save(ref domHead, ref domBody, VoucherState, ref vouchId, ref domCur); _logInfo.Debug("保存结束..."); _logInfo.Debug(errorMsg); @@ -153,28 +159,12 @@ namespace UFIDA.U8.Framework.Api.ControlObject.SA res.voucherId = $"{vouchId}"; res.result = errorMsg; - } - catch (Exception) - { - try - { - if (bAudit) - baseLogin.Connection.RollbackTrans(); - } - catch (Exception ex) - { - Trace.WriteLine(ex.Message); - } - - throw; - } if (!res.bSuccess) { res.message = "保存失败"; - if (bAudit) - baseLogin.Connection.RollbackTrans(); + return res; } @@ -192,14 +182,12 @@ namespace UFIDA.U8.Framework.Api.ControlObject.SA if (!string.IsNullOrWhiteSpace(errorMsg)) { - baseLogin.Connection.RollbackTrans(); throw new Exception(errorMsg); } } catch (Exception) { - baseLogin.Connection.RollbackTrans(); res.bSuccess = false; throw; } @@ -207,10 +195,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.SA _logInfo.Debug("提交事务..."); - baseLogin.Connection.CommitTrans(); - - - return res; + return res; } @@ -224,7 +209,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.SA } } - public async Task> VerifyVouch(dynamic voucherCO, Connection conn, VoucherTypeSA sVouchType, string cCode, object vouchId, string strWhere,bool bVerify) + public async Task> VerifyVouch(dynamic voucherCO, Connection conn, VoucherTypeSA sVouchType, string cCode, object vouchId, string strWhere, bool bVerify) { IXMLDOMDocument2 domHead = new DOMDocument(); IXMLDOMDocument2 domBody = new DOMDocument(); diff --git a/UFIDA.U8.Framework.Api/App_Data/U8API.xml b/UFIDA.U8.Framework.Api/App_Data/U8API.xml index 875ccb9..82674e4 100644 --- a/UFIDA.U8.Framework.Api/App_Data/U8API.xml +++ b/UFIDA.U8.Framework.Api/App_Data/U8API.xml @@ -594,6 +594,14 @@ + + + 查询计量单位组档案 + + + + + 查询部门档案 @@ -666,6 +674,12 @@ + + + 基础档案查询 + + + 应收应付管理 @@ -814,21 +828,16 @@ 日志组件 - + - 查询生产订单 + 查询特定单据部分 - - - - - - - 查询生产订单子件用料表 - - - + 系统号 + 单据类型编码 + 查询条件 + 查询所属区域 H:表头,B:表体 + @@ -989,7 +998,7 @@ 系统号 单据类型编码 查询条件 - 查询所属区域 H:表头,B:表体 + 查询所属区域 H:表头,B:表体, L:列表 @@ -1009,6 +1018,17 @@ + + + 查询特定单据部分 + + 系统号 + 单据类型编码 + 查询条件 + 查询所属区域 H:表头,B:表体 + + + 车间管理 diff --git a/UFIDA.U8.Framework.Api/App_Data/发货单模板.json b/UFIDA.U8.Framework.Api/App_Data/发货单模板.json new file mode 100644 index 0000000..99e1f96 --- /dev/null +++ b/UFIDA.U8.Framework.Api/App_Data/发货单模板.json @@ -0,0 +1,57 @@ + + { + "dlid": 1000000107, + "cbustype": "普通销售", + "cvouchtype": "05", + "cvouchname": "发货单", + "cstcode": "01", + "cstname": "普通销售", + "ddate": "2025-09-02", + "cdepcode": "0301", + "cdepname": "市场部", + "cpersoncode": "00024", + "cpersonname": "刘天达", + "csocode": "0000000001", + "ccuscode": "00000001", + "ccusabbname": "世纪天华", + "csccode": "04", + "cscname": "汽车", + "cexch_name": "人民币", + "iexchrate": 1.000000000000000e+000, + "itaxrate": 0.000000000000000e+000, + "breturnflag": 0, + "cmaker": "demo", + "bfirst": false, + "ccusname": "世纪天华集团公司", + "body": [ + { + "cwhname": "成品库", + "cwhcode": "04", + "cinvcode": "W1000A002", + "cinvname": "三星打印机", + "cinvm_unit": "台", + "igrouptype": 0, + "cgroupcode": "01", + "iquantity": 50.0000000000, + "iquotedprice": 1200.0000000000, + "itaxunitprice": 1200.0000000000, + "iunitprice": 1200.0000000000, + "imoney": 60000.0000, + "itax": 0.0000, + "idiscount": 0.0000, + "inatunitprice": 1200.0000000000, + "inatmoney": 60000.0000, + "inattax": 0.0000, + "inatsum": 60000.0000, + "inatdiscount": 0.0000, + "isum": 60000.0000, + "kl": 100.0000000000, + "kl2": 100.0000000000, + "itaxrate": 0.0000000000, + "isosid": 1000000001, + "csocode": "0000000001", + "dkl1": 0.0000000000, + "dkl2": 0.0000000000 + } + ] + } diff --git a/UFIDA.U8.Framework.Api/App_Data/销售发票模板.json b/UFIDA.U8.Framework.Api/App_Data/销售发票模板.json index f40fa42..ad93f59 100644 --- a/UFIDA.U8.Framework.Api/App_Data/销售发票模板.json +++ b/UFIDA.U8.Framework.Api/App_Data/销售发票模板.json @@ -3,9 +3,8 @@ "csysbarcode": "", "ccurrentauditor": "", "ivtid": "17", - "ufts": "", "csource": "销售", - "ccrechpname" :"", + "ccrechpname": "", "cinfotypecode": "", "cstcode": "06", "retail_id": "", diff --git a/UFIDA.U8.Framework.Api/Controllers/U8/AAController.cs b/UFIDA.U8.Framework.Api/Controllers/U8/AAController.cs index 0df3a2c..566c9cd 100644 --- a/UFIDA.U8.Framework.Api/Controllers/U8/AAController.cs +++ b/UFIDA.U8.Framework.Api/Controllers/U8/AAController.cs @@ -7,6 +7,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; using System.Web.Http; +using Antlr.Runtime; using UFIDA.U8.Framework.Api.ControlObject.Entity; using UFIDA.U8.Framework.Api.ControlObject.Json; using UFIDA.U8.Framework.Api.ControlObject.U8M; @@ -39,163 +40,13 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 [Route("api/U8/AA/Inventory/Load")] public async Task> Inventory_Load(string cAccId, [FromBody] Dictionary input) { - var workId = SnowFlakeSingle.Instance.NextId(); - - try + var dict = new Dictionary() { - //var userToken = Request.Headers.GetValues("userToken").First(); + { "Inventory", "" }, + { "Inventory_Sub", "Inventory_Sub.cInvSubCode=Inventory.cInvCode" }, + }; - //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") - //{ - // throw new Exception("调用信息不正确,请确认参数"); - //} - - _logInfo.Debug($"作业Id:{workId}-----档案:Inventory,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); - - if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) - { - _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); - - baseLogin = new BaseLogin(); - - var param = await CommUnit.GetLoginParamter(cAccId); - - if (param == null) - { - throw new Exception("未能加载指定系统号的登录信息"); - } - - baseLogin.Init(param, false); - - _cache.Clear(); - - _cache.Set($"U8_{cAccId}", baseLogin); - } - - var inventoryTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"App_Data/Inventory.json")); - - var inventorys = inventoryTxt.ToObject>(); - - var db = new SqlSugarClient(new ConnectionConfig() - { - DbType = DbType.SqlServer, ConfigId = cAccId, ConnectionString = baseLogin.UFDataConnstringForNet - }); - - var query = db.Queryable().AS("Inventory", "Inventory") - .AddJoinInfo("Inventory_Sub", "Inventory_Sub", "Inventory.cInvCode=Inventory_Sub.cInvSubCode"); - - if (db.DbMaintenance.IsAnyTable("Inventory_extradefine", false)) - { - query.AddJoinInfo("Inventory_extradefine", "Inventory_extradefine", - "Inventory.cInvCode=Inventory_extradefine.cInvCode"); - } - - if (input != null) - { - var conModels = new List(); - - - foreach (var o in input) - { - if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.Like, - FieldValue = $"{o.Value}" - }); - } - else if (o.Key == "cInvCode" && input.ContainsKey($"{o.Key}__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = "Inventory.cInvCode", - ConditionalType = ConditionalType.GreaterThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else if (o.Key == "cInvCode") - { - conModels.Add(new ConditionalModel - { - FieldName = "Inventory.cInvCode", - ConditionalType = ConditionalType.Equal, - FieldValue = $"{o.Value}" - }); - } - else if (o.Key == "cInvCode__2") - { - conModels.Add(new ConditionalModel - { - FieldName = "Inventory.cInvCode", - ConditionalType = ConditionalType.LessThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else if (o.Key.EndsWith("__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key.Replace("__2", "")}", - ConditionalType = ConditionalType.LessThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else if (input.ContainsKey($"{o.Key}__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.GreaterThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else - { - conModels.Add(new ConditionalModel - { - FieldName = o.Key, - ConditionalType = ConditionalType.Equal, - FieldValue = $"{o.Value}" - }); - } - } - - query.Where(conModels); - } - - if (inventorys != null && inventorys.Count > 0) - { - var selector = new List(); - - foreach (var inventory in inventorys) - { - var model = new SelectModel() { FieldName = $"{inventory.TableName}.{inventory.FieldName}" }; - - if (inventory.AsName != null && !string.IsNullOrWhiteSpace(inventory.AsName)) - { - model.AsName = inventory.AsName; - } - - selector.Add(model); - } - - query.Select(selector); - } - - _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); - - return new BaseResult - { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; - - } - catch (Exception ex) - { - _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); - - return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; - } + return await BaseLoad(cAccId, "Inventory", dict, input); } /// @@ -208,131 +59,30 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 [Route("api/U8/AA/ComputationUnit/Load")] public async Task> ComputationUnit_Load(string cAccId, [FromBody] Dictionary input) { - var workId = SnowFlakeSingle.Instance.NextId(); - - try + var dict = new Dictionary() { - //var userToken = Request.Headers.GetValues("userToken").First(); + { "ComputationUnit", "" }, + }; - //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") - //{ - // throw new Exception("调用信息不正确,请确认参数"); - //} + return await BaseLoad(cAccId, "ComputationUnit", dict, input); + } - _logInfo.Debug($"作业Id:{workId}-----档案:ComputationUnit,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); - - if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) - { - _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); - - baseLogin = new BaseLogin(); - - var param = await CommUnit.GetLoginParamter(cAccId); - - if (param == null) - { - throw new Exception("未能加载指定系统号的登录信息"); - } - - baseLogin.Init(param, false); - - _cache.Clear(); - - _cache.Set($"U8_{cAccId}", baseLogin); - } - - var computationunitTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/ComputationUnit.json")); - - var computationunits = computationunitTxt.ToObject>(); - - var db = new SqlSugarClient(new ConnectionConfig() - { - DbType = DbType.SqlServer, - ConfigId = cAccId, - ConnectionString = baseLogin.UFDataConnstringForNet - }); - - var query = db.Queryable().AS("ComputationUnit", "ComputationUnit"); - - - if (input != null) - { - var conModels = new List(); - - - foreach (var o in input) - { - if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.Like, - FieldValue = $"{o.Value}" - }); - }else if (o.Key.EndsWith("__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key.Replace("__2", "")}", - ConditionalType = ConditionalType.LessThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else if (input.ContainsKey($"{o.Key}__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.GreaterThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else - { - conModels.Add(new ConditionalModel - { - FieldName = o.Key, - ConditionalType = ConditionalType.Equal, - FieldValue = $"{o.Value}" - }); - } - } - - query.Where(conModels); - } - - if (computationunits != null && computationunits.Count > 0) - { - var selector = new List(); - - foreach (var computationunit in computationunits) - { - var model = new SelectModel() { FieldName = $"{computationunit.TableName}.{computationunit.FieldName}" }; - - if (computationunit.AsName != null && !string.IsNullOrWhiteSpace(computationunit.AsName)) - { - model.AsName = computationunit.AsName; - } - - selector.Add(model); - } - - query.Select(selector); - } - - _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); - - return new BaseResult - { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; - - } - catch (Exception ex) + /// + /// 查询计量单位组档案 + /// + /// + /// + /// + [HttpPost] + [Route("api/U8/AA/ComputationGroup/Load")] + public async Task> ComputationGroup_Load(string cAccId, [FromBody] Dictionary input) + { + var dict = new Dictionary() { - _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); + { "ComputationGroup", "" }, + }; - return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; - } + return await BaseLoad(cAccId, "ComputationGroup", dict, input); } /// @@ -345,130 +95,12 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 [Route("api/U8/AA/Department/Load")] public async Task> Department_Load(string cAccId, [FromBody] Dictionary input) { - var workId = SnowFlakeSingle.Instance.NextId(); - - try + var dict = new Dictionary() { - //var userToken = Request.Headers.GetValues("userToken").First(); + { "Department", "" }, + }; - //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") - //{ - // throw new Exception("调用信息不正确,请确认参数"); - //} - - _logInfo.Debug($"作业Id:{workId}-----档案:Department,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); - - if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) - { - _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); - - baseLogin = new BaseLogin(); - - var param = await CommUnit.GetLoginParamter(cAccId); - - if (param == null) - { - throw new Exception("未能加载指定系统号的登录信息"); - } - - baseLogin.Init(param, false); - - _cache.Clear(); - - _cache.Set($"U8_{cAccId}", baseLogin); - } - - var departmentTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Department.json")); - - var departments = departmentTxt.ToObject>(); - - var db = new SqlSugarClient(new ConnectionConfig() - { - DbType = DbType.SqlServer, - ConfigId = cAccId, - ConnectionString = baseLogin.UFDataConnstringForNet - }); - - var query = db.Queryable().AS("Department", "Department"); - - if (input != null) - { - var conModels = new List(); - - foreach (var o in input) - { - if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.Like, - FieldValue = $"{o.Value}" - }); - } - else if (o.Key.EndsWith("__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key.Replace("__2", "")}", - ConditionalType = ConditionalType.LessThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else if (input.ContainsKey($"{o.Key}__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.GreaterThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else - { - conModels.Add(new ConditionalModel - { - FieldName = o.Key, - ConditionalType = ConditionalType.Equal, - FieldValue = $"{o.Value}" - }); - } - } - - query.Where(conModels); - } - - if (departments != null && departments.Count > 0) - { - var selector = new List(); - - foreach (var department in departments) - { - var model = new SelectModel() { FieldName = $"{department.TableName}.{department.FieldName}" }; - - if (department.AsName != null && !string.IsNullOrWhiteSpace(department.AsName)) - { - model.AsName = department.AsName; - } - - selector.Add(model); - } - - query.Select(selector); - } - - _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); - - return new BaseResult - { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; - - } - catch (Exception ex) - { - _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); - - return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; - } + return await BaseLoad(cAccId, "Department", dict, input); } /// @@ -481,130 +113,12 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 [Route("api/U8/AA/Warehouse/Load")] public async Task> Warehouse_Load(string cAccId, [FromBody] Dictionary input) { - var workId = SnowFlakeSingle.Instance.NextId(); - - try + var dict = new Dictionary() { - //var userToken = Request.Headers.GetValues("userToken").First(); + { "Warehouse", "" }, + }; - //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") - //{ - // throw new Exception("调用信息不正确,请确认参数"); - //} - - _logInfo.Debug($"作业Id:{workId}-----档案:Warehouse,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); - - if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) - { - _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); - - baseLogin = new BaseLogin(); - - var param = await CommUnit.GetLoginParamter(cAccId); - - if (param == null) - { - throw new Exception("未能加载指定系统号的登录信息"); - } - - baseLogin.Init(param, false); - - _cache.Clear(); - - _cache.Set($"U8_{cAccId}", baseLogin); - } - - var warehouseTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Warehouse.json")); - - var warehouses = warehouseTxt.ToObject>(); - - var db = new SqlSugarClient(new ConnectionConfig() - { - DbType = DbType.SqlServer, - ConfigId = cAccId, - ConnectionString = baseLogin.UFDataConnstringForNet - }); - - var query = db.Queryable().AS("Warehouse", "Warehouse"); - - if (input != null) - { - var conModels = new List(); - - foreach (var o in input) - { - if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.Like, - FieldValue = $"{o.Value}" - }); - } - else if (o.Key.EndsWith("__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key.Replace("__2", "")}", - ConditionalType = ConditionalType.LessThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else if (input.ContainsKey($"{o.Key}__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.GreaterThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else - { - conModels.Add(new ConditionalModel - { - FieldName = o.Key, - ConditionalType = ConditionalType.Equal, - FieldValue = $"{o.Value}" - }); - } - } - - query.Where(conModels); - } - - if (warehouses != null && warehouses.Count > 0) - { - var selector = new List(); - - foreach (var warehouse in warehouses) - { - var model = new SelectModel() { FieldName = $"{warehouse.TableName}.{warehouse.FieldName}" }; - - if (warehouse.AsName != null && !string.IsNullOrWhiteSpace(warehouse.AsName)) - { - model.AsName = warehouse.AsName; - } - - selector.Add(model); - } - - query.Select(selector); - } - - _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); - - return new BaseResult - { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; - - } - catch (Exception ex) - { - _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); - - return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; - } + return await BaseLoad(cAccId, "Warehouse", dict, input); } /// @@ -617,130 +131,12 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 [Route("api/U8/AA/InventoryClass/Load")] public async Task> InventoryClass_Load(string cAccId, [FromBody] Dictionary input) { - var workId = SnowFlakeSingle.Instance.NextId(); - - try + var dict = new Dictionary() { - //var userToken = Request.Headers.GetValues("userToken").First(); + { "InventoryClass", "" }, + }; - //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") - //{ - // throw new Exception("调用信息不正确,请确认参数"); - //} - - _logInfo.Debug($"作业Id:{workId}-----档案:InventoryClass,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); - - if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) - { - _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); - - baseLogin = new BaseLogin(); - - var param = await CommUnit.GetLoginParamter(cAccId); - - if (param == null) - { - throw new Exception("未能加载指定系统号的登录信息"); - } - - baseLogin.Init(param, false); - - _cache.Clear(); - - _cache.Set($"U8_{cAccId}", baseLogin); - } - - var inventoryclassTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/InventoryClass.json")); - - var inventoryclasss = inventoryclassTxt.ToObject>(); - - var db = new SqlSugarClient(new ConnectionConfig() - { - DbType = DbType.SqlServer, - ConfigId = cAccId, - ConnectionString = baseLogin.UFDataConnstringForNet - }); - - var query = db.Queryable().AS("InventoryClass", "InventoryClass"); - - if (input != null) - { - var conModels = new List(); - - foreach (var o in input) - { - if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.Like, - FieldValue = $"{o.Value}" - }); - } - else if (o.Key.EndsWith("__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key.Replace("__2", "")}", - ConditionalType = ConditionalType.LessThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else if (input.ContainsKey($"{o.Key}__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.GreaterThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else - { - conModels.Add(new ConditionalModel - { - FieldName = o.Key, - ConditionalType = ConditionalType.Equal, - FieldValue = $"{o.Value}" - }); - } - } - - query.Where(conModels); - } - - if (inventoryclasss != null && inventoryclasss.Count > 0) - { - var selector = new List(); - - foreach (var inventoryclass in inventoryclasss) - { - var model = new SelectModel() { FieldName = $"{inventoryclass.TableName}.{inventoryclass.FieldName}" }; - - if (inventoryclass.AsName != null && !string.IsNullOrWhiteSpace(inventoryclass.AsName)) - { - model.AsName = inventoryclass.AsName; - } - - selector.Add(model); - } - - query.Select(selector); - } - - _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); - - return new BaseResult - { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; - - } - catch (Exception ex) - { - _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); - - return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; - } + return await BaseLoad(cAccId, "Vendor", dict, input); } /// @@ -753,130 +149,15 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 [Route("api/U8/AA/Vendor/Load")] public async Task> Vendor_Load(string cAccId, [FromBody] Dictionary input) { - var workId = SnowFlakeSingle.Instance.NextId(); - - try + var dict = new Dictionary() { - //var userToken = Request.Headers.GetValues("userToken").First(); + { "Vendor", "" }, + //{ "VendorClass", "VendorClass.cVCCode = Vendor.cVCCode" }, + //{ "DistrictClass", "DistrictClass.cDCCode = Vendor.cDCCode" }, + //{ "Person", "Person.cPersonCode = dbo.Vendor.cVenPPerson" }, + }; - //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") - //{ - // throw new Exception("调用信息不正确,请确认参数"); - //} - - _logInfo.Debug($"作业Id:{workId}-----档案:Vendor,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); - - if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) - { - _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); - - baseLogin = new BaseLogin(); - - var param = await CommUnit.GetLoginParamter(cAccId); - - if (param == null) - { - throw new Exception("未能加载指定系统号的登录信息"); - } - - baseLogin.Init(param, false); - - _cache.Clear(); - - _cache.Set($"U8_{cAccId}", baseLogin); - } - - var vendorTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Vendor.json")); - - var vendors = vendorTxt.ToObject>(); - - var db = new SqlSugarClient(new ConnectionConfig() - { - DbType = DbType.SqlServer, - ConfigId = cAccId, - ConnectionString = baseLogin.UFDataConnstringForNet - }); - - var query = db.Queryable().AS("Vendor", "Vendor"); - - if (input != null) - { - var conModels = new List(); - - foreach (var o in input) - { - if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.Like, - FieldValue = $"{o.Value}" - }); - } - else if (o.Key.EndsWith("__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key.Replace("__2", "")}", - ConditionalType = ConditionalType.LessThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else if (input.ContainsKey($"{o.Key}__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.GreaterThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else - { - conModels.Add(new ConditionalModel - { - FieldName = o.Key, - ConditionalType = ConditionalType.Equal, - FieldValue = $"{o.Value}" - }); - } - } - - query.Where(conModels); - } - - if (vendors != null && vendors.Count > 0) - { - var selector = new List(); - - foreach (var vendor in vendors) - { - var model = new SelectModel() { FieldName = $"{vendor.TableName}.{vendor.FieldName}" }; - - if (vendor.AsName != null && !string.IsNullOrWhiteSpace(vendor.AsName)) - { - model.AsName = vendor.AsName; - } - - selector.Add(model); - } - - query.Select(selector); - } - - _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); - - return new BaseResult - { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; - - } - catch (Exception ex) - { - _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); - - return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; - } + return await BaseLoad(cAccId, "Vendor", dict, input); } /// @@ -889,130 +170,12 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 [Route("api/U8/AA/VendorClass/Load")] public async Task> VendorClass_Load(string cAccId, [FromBody] Dictionary input) { - var workId = SnowFlakeSingle.Instance.NextId(); - - try + var dict = new Dictionary() { - //var userToken = Request.Headers.GetValues("userToken").First(); + { "VendorClass", "" }, + }; - //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") - //{ - // throw new Exception("调用信息不正确,请确认参数"); - //} - - _logInfo.Debug($"作业Id:{workId}-----档案:VendorClass,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); - - if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) - { - _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); - - baseLogin = new BaseLogin(); - - var param = await CommUnit.GetLoginParamter(cAccId); - - if (param == null) - { - throw new Exception("未能加载指定系统号的登录信息"); - } - - baseLogin.Init(param, false); - - _cache.Clear(); - - _cache.Set($"U8_{cAccId}", baseLogin); - } - - var queryTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/VendorClass.json")); - - var querys = queryTxt.ToObject>(); - - var db = new SqlSugarClient(new ConnectionConfig() - { - DbType = DbType.SqlServer, - ConfigId = cAccId, - ConnectionString = baseLogin.UFDataConnstringForNet - }); - - var query = db.Queryable().AS("VendorClass", "VendorClass"); - - if (input != null) - { - var conModels = new List(); - - foreach (var o in input) - { - if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.Like, - FieldValue = $"{o.Value}" - }); - } - else if (o.Key.EndsWith("__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key.Replace("__2", "")}", - ConditionalType = ConditionalType.LessThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else if (input.ContainsKey($"{o.Key}__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.GreaterThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else - { - conModels.Add(new ConditionalModel - { - FieldName = o.Key, - ConditionalType = ConditionalType.Equal, - FieldValue = $"{o.Value}" - }); - } - } - - query.Where(conModels); - } - - if (querys != null && querys.Count > 0) - { - var selector = new List(); - - foreach (var q in querys) - { - var model = new SelectModel() { FieldName = $"{q.TableName}.{q.FieldName}" }; - - if (q.AsName != null && !string.IsNullOrWhiteSpace(q.AsName)) - { - model.AsName = q.AsName; - } - - selector.Add(model); - } - - query.Select(selector); - } - - _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); - - return new BaseResult - { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; - - } - catch (Exception ex) - { - _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); - - return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; - } + return await BaseLoad(cAccId, "VendorClass", dict, input); } /// @@ -1025,130 +188,17 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 [Route("api/U8/AA/Customer/Load")] public async Task> Customer_Load(string cAccId, [FromBody] Dictionary input) { - var workId = SnowFlakeSingle.Instance.NextId(); - - try + var dict = new Dictionary() { - //var userToken = Request.Headers.GetValues("userToken").First(); + { "Customer", "" }, + //{ "CustomerClass", "Customer.cCCCode = CustomerClass.cCCCode" }, + //{ "DistrictClass", "DistrictClass.cDCCode = Customer.cDCCode" }, + //{ "DistrictClass", "DistrictClass.cDCCode = Customer.cDCCode" }, + //{ "Person", "Person.cPersonCode = Customer.cCusPerson" }, + //{ "Warehouse", "Warehouse.cWhCode = Customer.cCusWhCode" }, + }; - //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") - //{ - // throw new Exception("调用信息不正确,请确认参数"); - //} - - _logInfo.Debug($"作业Id:{workId}-----档案:Customer,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); - - if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) - { - _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); - - baseLogin = new BaseLogin(); - - var param = await CommUnit.GetLoginParamter(cAccId); - - if (param == null) - { - throw new Exception("未能加载指定系统号的登录信息"); - } - - baseLogin.Init(param, false); - - _cache.Clear(); - - _cache.Set($"U8_{cAccId}", baseLogin); - } - - var queryTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Customer.json")); - - var querys = queryTxt.ToObject>(); - - var db = new SqlSugarClient(new ConnectionConfig() - { - DbType = DbType.SqlServer, - ConfigId = cAccId, - ConnectionString = baseLogin.UFDataConnstringForNet - }); - - var query = db.Queryable().AS("Customer", "Customer"); - - if (input != null) - { - var conModels = new List(); - - foreach (var o in input) - { - if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.Like, - FieldValue = $"{o.Value}" - }); - } - else if (o.Key.EndsWith("__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key.Replace("__2", "")}", - ConditionalType = ConditionalType.LessThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else if (input.ContainsKey($"{o.Key}__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.GreaterThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else - { - conModels.Add(new ConditionalModel - { - FieldName = o.Key, - ConditionalType = ConditionalType.Equal, - FieldValue = $"{o.Value}" - }); - } - } - - query.Where(conModels); - } - - if (querys != null && querys.Count > 0) - { - var selector = new List(); - - foreach (var q in querys) - { - var model = new SelectModel() { FieldName = $"{q.TableName}.{q.FieldName}" }; - - if (q.AsName != null && !string.IsNullOrWhiteSpace(q.AsName)) - { - model.AsName = q.AsName; - } - - selector.Add(model); - } - - query.Select(selector); - } - - _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); - - return new BaseResult - { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; - - } - catch (Exception ex) - { - _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); - - return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; - } + return await BaseLoad(cAccId, "Customer", dict, input); } /// @@ -1161,130 +211,12 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 [Route("api/U8/AA/CustomerClass/Load")] public async Task> CustomerClass_Load(string cAccId, [FromBody] Dictionary input) { - var workId = SnowFlakeSingle.Instance.NextId(); - - try + var dict = new Dictionary() { - //var userToken = Request.Headers.GetValues("userToken").First(); + { "CustomerClass", "" }, + }; - //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") - //{ - // throw new Exception("调用信息不正确,请确认参数"); - //} - - _logInfo.Debug($"作业Id:{workId}-----档案:CustomerClass,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); - - if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) - { - _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); - - baseLogin = new BaseLogin(); - - var param = await CommUnit.GetLoginParamter(cAccId); - - if (param == null) - { - throw new Exception("未能加载指定系统号的登录信息"); - } - - baseLogin.Init(param, false); - - _cache.Clear(); - - _cache.Set($"U8_{cAccId}", baseLogin); - } - - var queryTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/CustomerClass.json")); - - var querys = queryTxt.ToObject>(); - - var db = new SqlSugarClient(new ConnectionConfig() - { - DbType = DbType.SqlServer, - ConfigId = cAccId, - ConnectionString = baseLogin.UFDataConnstringForNet - }); - - var query = db.Queryable().AS("CustomerClass", "CustomerClass"); - - if (input != null) - { - var conModels = new List(); - - foreach (var o in input) - { - if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.Like, - FieldValue = $"{o.Value}" - }); - } - else if (o.Key.EndsWith("__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key.Replace("__2", "")}", - ConditionalType = ConditionalType.LessThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else if (input.ContainsKey($"{o.Key}__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.GreaterThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else - { - conModels.Add(new ConditionalModel - { - FieldName = o.Key, - ConditionalType = ConditionalType.Equal, - FieldValue = $"{o.Value}" - }); - } - } - - query.Where(conModels); - } - - if (querys != null && querys.Count > 0) - { - var selector = new List(); - - foreach (var q in querys) - { - var model = new SelectModel() { FieldName = $"{q.TableName}.{q.FieldName}" }; - - if (q.AsName != null && !string.IsNullOrWhiteSpace(q.AsName)) - { - model.AsName = q.AsName; - } - - selector.Add(model); - } - - query.Select(selector); - } - - _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); - - return new BaseResult - { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; - - } - catch (Exception ex) - { - _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); - - return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; - } + return await BaseLoad(cAccId, "CustomerClass", dict, input); } /// @@ -1297,130 +229,13 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 [Route("api/U8/AA/Person/Load")] public async Task> Person_Load(string cAccId, [FromBody] Dictionary input) { - var workId = SnowFlakeSingle.Instance.NextId(); - - try + var dict = new Dictionary() { - //var userToken = Request.Headers.GetValues("userToken").First(); + { "hr_hi_person", "" }, + //{ "Department", "Department.cDepCode = hr_hi_person.cDept_num" } + }; - //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") - //{ - // throw new Exception("调用信息不正确,请确认参数"); - //} - - _logInfo.Debug($"作业Id:{workId}-----档案:CustomerClass,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); - - if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) - { - _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); - - baseLogin = new BaseLogin(); - - var param = await CommUnit.GetLoginParamter(cAccId); - - if (param == null) - { - throw new Exception("未能加载指定系统号的登录信息"); - } - - baseLogin.Init(param, false); - - _cache.Clear(); - - _cache.Set($"U8_{cAccId}", baseLogin); - } - - var queryTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Person.json")); - - var querys = queryTxt.ToObject>(); - - var db = new SqlSugarClient(new ConnectionConfig() - { - DbType = DbType.SqlServer, - ConfigId = cAccId, - ConnectionString = baseLogin.UFDataConnstringForNet - }); - - var query = db.Queryable().AS("hr_hi_person", "hr_hi_person"); - - if (input != null) - { - var conModels = new List(); - - foreach (var o in input) - { - if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.Like, - FieldValue = $"{o.Value}" - }); - } - else if (o.Key.EndsWith("__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key.Replace("__2", "")}", - ConditionalType = ConditionalType.LessThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else if (input.ContainsKey($"{o.Key}__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.GreaterThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else - { - conModels.Add(new ConditionalModel - { - FieldName = o.Key, - ConditionalType = ConditionalType.Equal, - FieldValue = $"{o.Value}" - }); - } - } - - query.Where(conModels); - } - - if (querys != null && querys.Count > 0) - { - var selector = new List(); - - foreach (var q in querys) - { - var model = new SelectModel() { FieldName = $"{q.TableName}.{q.FieldName}" }; - - if (q.AsName != null && !string.IsNullOrWhiteSpace(q.AsName)) - { - model.AsName = q.AsName; - } - - selector.Add(model); - } - - query.Select(selector); - } - - _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); - - return new BaseResult - { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; - - } - catch (Exception ex) - { - _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); - - return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; - } + return await BaseLoad(cAccId, "Person", dict, input); } /// @@ -1432,19 +247,32 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 [HttpPost] [Route("api/U8/AA/Operation/Load")] public async Task> Operation_Load(string cAccId, [FromBody] Dictionary input) + { + var dict = new Dictionary() + { + { "sfc_operation", "" } + }; + + return await BaseLoad(cAccId, "Operation", dict, input); + } + + /// + /// 基础档案查询 + /// + /// + [NonAction] + public async Task> BaseLoad(string cAccId, string tableName,Dictionary tables, [FromBody] Dictionary input=null) { var workId = SnowFlakeSingle.Instance.NextId(); try { - //var userToken = Request.Headers.GetValues("userToken").First(); + _logInfo.Debug($"作业Id:{workId}-----档案:{tableName},操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); - //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") - //{ - // throw new Exception("调用信息不正确,请确认参数"); - //} - - _logInfo.Debug($"作业Id:{workId}-----档案:Operation,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); + if (tables == null || tables.Count == 0) + { + throw new Exception("未指定档案表"); + } if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) { @@ -1466,18 +294,50 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 _cache.Set($"U8_{cAccId}", baseLogin); } - var queryTxt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/Operation.json")); - - var querys = queryTxt.ToObject>(); - var db = new SqlSugarClient(new ConnectionConfig() { DbType = DbType.SqlServer, ConfigId = cAccId, - ConnectionString = baseLogin.UFDataConnstringForNet + ConnectionString = baseLogin.UFDataConnstringForNet, + IsAutoCloseConnection = true, + MoreSettings = new ConnMoreSettings() + { + IsWithNoLockQuery = true + } }); - var query = db.Queryable().AS("sfc_operation", "sfc_operation"); + var colList = new Dictionary(); + + var query = db.Queryable(); + var bFirst = true; + + foreach (var table in tables) + { + if (!db.DbMaintenance.IsAnyTable(table.Key)) + { + throw new Exception($"表:{table.Key}不存在"); + } + + var cols = db.DbMaintenance.GetColumnInfosByTableName(table.Key); + + if(cols != null && cols.Count > 0) + { + foreach (var col in cols.Where(col => !colList.Any(a => string.Equals(a.Key, col.DbColumnName, StringComparison.CurrentCultureIgnoreCase)))) + { + colList.Add(col.DbColumnName, $"{table.Key}.[{col.DbColumnName}]"); + } + } + + if (bFirst) + { + query.AS(table.Key, table.Key); + bFirst = false; + } + else + { + query.AddJoinInfo(table.Key, table.Key, table.Value); + } + } if (input != null) { @@ -1512,7 +372,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 FieldValue = $"{o.Value}" }); } - else + else if (colList.Keys.Contains(o.Key) || colList.Values.Contains(o.Key)) { conModels.Add(new ConditionalModel { @@ -1526,29 +386,17 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 query.Where(conModels); } - if (querys != null && querys.Count > 0) + if (colList != null && colList.Keys.Count > 0) { - var selector = new List(); - - foreach (var q in querys) - { - var model = new SelectModel() { FieldName = $"{q.TableName}.{q.FieldName}" }; - - if (q.AsName != null && !string.IsNullOrWhiteSpace(q.AsName)) - { - model.AsName = q.AsName; - } - - selector.Add(model); - } + var selector = colList + .Select(col => new SelectModel { FieldName = $"{col.Value}", AsName = col.Key }).ToList(); query.Select(selector); } _logInfo.Debug($"作业Id:{workId}-----输出查询语句:{query.ToSqlString()}"); - return new BaseResult - { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; + return new BaseResult { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; } catch (Exception ex) diff --git a/UFIDA.U8.Framework.Api/Controllers/U8/MOController.cs b/UFIDA.U8.Framework.Api/Controllers/U8/MOController.cs index 02b6b4b..85951e9 100644 --- a/UFIDA.U8.Framework.Api/Controllers/U8/MOController.cs +++ b/UFIDA.U8.Framework.Api/Controllers/U8/MOController.cs @@ -7,6 +7,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; using System.Web.Http; +using UFIDA.U8.Framework.Api.ControlObject.Common; using UFIDA.U8.Framework.Api.ControlObject.Entity; using UFIDA.U8.Framework.Api.ControlObject.Json; using UFIDA.U8.Framework.Api.ControlObject.U8M; @@ -28,27 +29,24 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 private static readonly MemoryCache _cache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromMinutes(10) }); /// - /// 查询生产订单 + /// 查询特定单据部分 /// - /// - /// + /// 系统号 + /// 单据类型编码 + /// 查询条件 + /// 查询所属区域 H:表头,B:表体 /// + /// [HttpPost] - [Route("api/U8/MO/MO21/Load")] - public async Task> MO21_Load(string cAccId,[FromBody] Dictionary input) + [Route("api/U8/MO/{cCardNum}/Load")] + [Route("api/U8/MO/{cCardNum}/Load/{cCardPostion}")] + public async Task> Load(string cAccId, string cCardNum, [FromBody] Dictionary input, string cCardPostion = "H") { var workId = SnowFlakeSingle.Instance.NextId(); try { - //var userToken = Request.Headers.GetValues("userToken").First(); - - //if (userToken!= "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") - //{ - // throw new Exception("调用信息不正确,请确认参数"); - //} - - _logInfo.Debug($"作业Id:{workId}-----单据:MO21,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) { @@ -70,30 +68,122 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 _cache.Set($"U8_{cAccId}", baseLogin); } + var vouchers = CommonHelper.GetVouchers(baseLogin.Connection, cCardNum); + + if (vouchers == null) + { + throw new Exception("未能获取到单据配置信息"); + } + var db = new SqlSugarClient(new ConnectionConfig() { DbType = DbType.SqlServer, ConfigId = cAccId, - ConnectionString = baseLogin.UFDataConnstringForNet + ConnectionString = baseLogin.UFDataConnstringForNet, + IsAutoCloseConnection = true, + MoreSettings = new ConnMoreSettings() + { + IsWithNoLockQuery = true + } }); - var mo21Txt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/MO21.json")); + var cBTTblName = vouchers.cBTTblName; + var cBWTblName = vouchers.cBWTblName; + var voucherIdFieldName = vouchers.voucherIdFieldName; + var vouchersIdFieldName = ""; + var tableName = cBTTblName; + var colsHeadList = new List(); + var colsBodyList = new List(); + var bExtHead = false; + var bExtBody = false; - var mo21s = mo21Txt.ToObject>(); - - var query = db.Queryable().AS("v_mom_order_wf", "v_mom_order_wf") - .AddJoinInfo("v_mom_orderdetail_wf", "v_mom_orderdetail_wf", "v_mom_order_wf.MoId=v_mom_orderdetail_wf.MoId"); - - if (db.DbMaintenance.IsAnyTable("mom_order_extradefine", false)) + if (cCardPostion == "H") { - query.AddJoinInfo("mom_order_extradefine", "mom_order_extradefine", - "v_mom_order_wf.MoId=mom_order_extradefine.MoId"); + tableName = cBTTblName; } - if (db.DbMaintenance.IsAnyTable("mom_orderdetail_extradefine", false)) + if (cCardPostion == "B") { - query.AddJoinInfo("mom_orderdetail_extradefine", "mom_order_extradefine", - "v_mom_orderdetail_wf.MoDId=mom_orderdetail_extradefine.MoDId"); + tableName = cBWTblName; + } + + if (cCardPostion == "L") + { + tableName = cBWTblName; + } + + var cDefWhere = vouchers.cDefWhere; + + var query = db.Queryable().AS(cBTTblName, cBTTblName); + + if (!string.IsNullOrWhiteSpace(cBWTblName)) + { + query.AddJoinInfo(cBWTblName, cBWTblName, $"{cBTTblName}.[{voucherIdFieldName}]={cBWTblName}.[{voucherIdFieldName}]"); + + var bodyCols = db.DbMaintenance.GetColumnInfosByTableName(cBWTblName); + + if (bodyCols != null && bodyCols.Count > 0) + { + colsBodyList.AddRange(from col in bodyCols where !col.DbColumnName.ToLower().Contains("ufts") && col.DbColumnName.ToLower() != voucherIdFieldName.ToLower() select $"{cBWTblName}.[{col.DbColumnName.ToLower()}]"); + + if (cCardPostion=="B" && !colsBodyList.Contains(voucherIdFieldName.ToLower())) + { + colsBodyList.Add($"{cBWTblName}.[{voucherIdFieldName.ToLower()}]"); + } + } + } + + var headCols = db.DbMaintenance.GetColumnInfosByTableName(cBTTblName); + + if (headCols != null && headCols.Count > 0) + { + colsHeadList.AddRange(from col in headCols where !col.DbColumnName.ToLower().Contains("ufts") select $"{cBTTblName}.[{col.DbColumnName}]"); + } + + if (db.DbMaintenance.IsAnyTable($"{cBTTblName}_extradefine", false)) + { + bExtHead = true; + var cols = db.DbMaintenance.GetColumnInfosByTableName($"{cBTTblName}_extradefine"); + + if (cols != null && cols.Count > 0) + { + foreach (var col in cols) + { + if (col.DbColumnName.ToLower().StartsWith("chdefine")) + { + colsHeadList.Add($"{cBTTblName}_extradefine.[{col.DbColumnName.ToLower()}]"); + } + else + { + vouchersIdFieldName = col.DbColumnName; + } + } + } + + query.AddJoinInfo($"{cBTTblName}_extradefine", $"{cBTTblName}_extradefine", $"{cBTTblName}.[{voucherIdFieldName}]={cBTTblName}_extradefine.[{voucherIdFieldName}]"); + } + + if (db.DbMaintenance.IsAnyTable($"{cBWTblName}_extradefine", false)) + { + bExtBody = true; + var cols = db.DbMaintenance.GetColumnInfosByTableName($"{cBWTblName}_extradefine"); + + if (cols != null && cols.Count > 0) + { + foreach (var col in cols) + { + if (col.DbColumnName.ToLower().StartsWith("cbdefine")) + { + colsBodyList.Add($"{cBWTblName}_extradefine.[{col.DbColumnName.ToLower()}]"); + } + else + { + vouchersIdFieldName = col.DbColumnName; + } + } + } + + query.AddJoinInfo($"{cBWTblName}_extradefine", $"{cBWTblName}_extradefine", $"{cBWTblName}.[{vouchersIdFieldName}]={cBWTblName}_extradefine.[{vouchersIdFieldName}]"); } if (input != null) @@ -102,56 +192,30 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 foreach (var o in input) { - if (o.Key == "MoId" && input.ContainsKey($"{o.Key}__2")) + if (o.Key == "dModifyDate") { conModels.Add(new ConditionalModel { - FieldName = "v_mom_order_wf.MoId", + FieldName = "RelsTime", ConditionalType = ConditionalType.GreaterThanOrEqual, FieldValue = $"{o.Value}" }); } - else if (o.Key == "MoId") + else if (o.Key == "dModifyDate__2") { conModels.Add(new ConditionalModel { - FieldName = "v_mom_order_wf.MoId", - ConditionalType = ConditionalType.Equal, - FieldValue = $"{o.Value}" - }); - } - else if (o.Key == "MoId__2") - { - conModels.Add(new ConditionalModel - { - FieldName = "v_mom_order_wf.MoId", + FieldName = "RelsTime", ConditionalType = ConditionalType.LessThanOrEqual, FieldValue = $"{o.Value}" }); - }else if (o.Key == "MoDId" && input.ContainsKey($"{o.Key}__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = "v_mom_orderdetail_wf.MoDId", - ConditionalType = ConditionalType.GreaterThanOrEqual, - FieldValue = $"{o.Value}" - }); } - else if (o.Key == "MoDId") + else if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) { conModels.Add(new ConditionalModel { - FieldName = "v_mom_orderdetail_wf.MoDId", - ConditionalType = ConditionalType.Equal, - FieldValue = $"{o.Value}" - }); - } - else if (o.Key == "MoDId__2") - { - conModels.Add(new ConditionalModel - { - FieldName = "v_mom_orderdetail_wf.MoDId", - ConditionalType = ConditionalType.LessThanOrEqual, + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.Like, FieldValue = $"{o.Value}" }); } @@ -187,193 +251,54 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 query.Where(conModels); } - if (mo21s != null && mo21s.Count > 0) + query.Where(cDefWhere); + + if (cCardPostion == "H") { - var selector = new List(); - - foreach (var mo21 in mo21s) + if (bExtHead) { - var model = new SelectModel() { FieldName = $"{mo21.TableName}.{mo21.FieldName}" }; - - if (mo21.AsName != null && !string.IsNullOrWhiteSpace(mo21.AsName)) - { - model.AsName = mo21.AsName; - } - - selector.Add(model); + query.Select($"{string.Join(",", colsHeadList)}").Distinct(); + } + else + { + query.Select($"{string.Join(",", colsHeadList)}").Distinct(); } - - query.Select(selector); } - return new BaseResult { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; + if (cCardPostion == "B") + { + if (bExtBody) + { + query.Select($"{string.Join(",", colsBodyList)}").Distinct(); + } + else + { + query.Select($"{string.Join(",", colsBodyList)}").Distinct(); + } + } + if (cCardPostion == "L") + { + colsBodyList.AddRange(colsHeadList); + + if (bExtBody) + { + query.Select($"{string.Join(",", colsBodyList)}").Distinct(); + } + else + { + query.Select($"{string.Join(",", colsBodyList)}").Distinct(); + } + } + + + _logInfo.Debug(query.ToSqlString()); + + return new BaseResult() { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; } catch (Exception ex) { - _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); - - await Task.Delay(1); - - return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; - } - } - - /// - /// 查询生产订单子件用料表 - /// - /// - /// - /// - [HttpPost] - [Route("api/U8/MO/MO2101/Load")] - public async Task> MO2101_Load(string cAccId, [FromBody] Dictionary input) - { - var workId = SnowFlakeSingle.Instance.NextId(); - - try - { - //var userToken = Request.Headers.GetValues("userToken").First(); - - //if (userToken != "04fafa004ad8851485d9026229964a488f2080907248680178bae68a236b33bc086aa234c94927e4099f21209bea98640ad4e9b1b5319cd5f55144606d82f3dbeff44ec66575ca2438144df9fa3f3e1babd80a140d2170975a031fca1ade326234b4d9a61386") - //{ - // throw new Exception("调用信息不正确,请确认参数"); - //} - - _logInfo.Debug($"作业Id:{workId}-----单据:MO2101,操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); - - - if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) - { - _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); - - baseLogin = new BaseLogin(); - - var param = await CommUnit.GetLoginParamter(cAccId); - - if (param == null) - { - throw new Exception("未能加载指定系统号的登录信息"); - } - - baseLogin.Init(param, false); - - _cache.Clear(); - - _cache.Set($"U8_{cAccId}", baseLogin); - } - - var db = new SqlSugarClient(new ConnectionConfig() - { - DbType = DbType.SqlServer, - ConfigId = cAccId, - ConnectionString = baseLogin.UFDataConnstringForNet - }); - - var mo2101Txt = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/MO2101.json")); - - var mo2101s = mo2101Txt.ToObject>(); - - var query = db.Queryable().AS("mom_moallocate", "mom_moallocate"); - - if (db.DbMaintenance.IsAnyTable("mom_moallocate_extradefine", false)) - { - query.AddJoinInfo("mom_moallocate_extradefine", "mom_moallocate_extradefinemom_moallocate_extradefine", - "om_moallocate.AllocateId=mom_moallocate_extradefine.AllocateId"); - } - - if (input != null) - { - var conModels = new List(); - - foreach (var o in input) - { - if (o.Key == "AllocateId" && input.ContainsKey($"{o.Key}__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = "mom_moallocate.AllocateId", - ConditionalType = ConditionalType.GreaterThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else if (o.Key == "AllocateId") - { - conModels.Add(new ConditionalModel - { - FieldName = "mom_moallocate.AllocateId", - ConditionalType = ConditionalType.Equal, - FieldValue = $"{o.Value}" - }); - } - else if (o.Key == "AllocateId__2") - { - conModels.Add(new ConditionalModel - { - FieldName = "mom_moallocate.AllocateId", - ConditionalType = ConditionalType.LessThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else if (o.Key.EndsWith("__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key.Replace("__2", "")}", - ConditionalType = ConditionalType.LessThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else if (input.ContainsKey($"{o.Key}__2")) - { - conModels.Add(new ConditionalModel - { - FieldName = $"{o.Key}", - ConditionalType = ConditionalType.GreaterThanOrEqual, - FieldValue = $"{o.Value}" - }); - } - else - { - conModels.Add(new ConditionalModel - { - FieldName = o.Key, - ConditionalType = ConditionalType.Equal, - FieldValue = $"{o.Value}" - }); - } - } - - query.Where(conModels); - } - - if (mo2101s != null && mo2101s.Count > 0) - { - var selector = new List(); - - foreach (var mo2101 in mo2101s) - { - var model = new SelectModel() { FieldName = $"{mo2101.TableName}.{mo2101.FieldName}" }; - - if (mo2101.AsName != null && !string.IsNullOrWhiteSpace(mo2101.AsName)) - { - model.AsName = mo2101.AsName; - } - - selector.Add(model); - } - - query.Select(selector); - } - - return new BaseResult { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; - - } - catch (Exception ex) - { - _logInfo.Error($"作业Id:{workId}-----错误信息:{ex.Message}", ex); - - await Task.Delay(1); + _logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; } diff --git a/UFIDA.U8.Framework.Api/Controllers/U8/PUController.cs b/UFIDA.U8.Framework.Api/Controllers/U8/PUController.cs index c6351b9..f6ed7e2 100644 --- a/UFIDA.U8.Framework.Api/Controllers/U8/PUController.cs +++ b/UFIDA.U8.Framework.Api/Controllers/U8/PUController.cs @@ -845,7 +845,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 /// 系统号 /// 单据类型编码 /// 查询条件 - /// 查询所属区域 H:表头,B:表体 + /// 查询所属区域 H:表头,B:表体, L:列表 /// /// [HttpPost] @@ -890,7 +890,12 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 { DbType = DbType.SqlServer, ConfigId = cAccId, - ConnectionString = baseLogin.UFDataConnstringForNet + ConnectionString = baseLogin.UFDataConnstringForNet, + IsAutoCloseConnection = true, + MoreSettings = new ConnMoreSettings() + { + IsWithNoLockQuery = true + } }); var cBTQName = vouchers.cBTQName; @@ -907,7 +912,7 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 if (cCardPostion == "H") { - tableName = cBWQName; + tableName = cBTQName; } if (cCardPostion == "B") @@ -915,6 +920,13 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 tableName = cBWQName; } + if (cCardPostion == "L") + { + tableName = cBWQName; + } + + + var cDefWhere = vouchers.cDefWhere; var query = db.Queryable().AS(cBTQName, cBTQName); @@ -927,7 +939,12 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 if (bodyCols != null && bodyCols.Count > 0) { - colsBodyList.AddRange(from col in bodyCols where !col.DbColumnName.ToLower().Contains("ufts") && col.DbColumnName.ToLower()!=voucherIdFieldName select $"{cBWQName}.[{col.DbColumnName}]"); + colsBodyList.AddRange(from col in bodyCols where !col.DbColumnName.ToLower().Contains("ufts") && col.DbColumnName.ToLower()!=voucherIdFieldName select $"{cBWQName}.[{col.DbColumnName.ToLower()}]"); + + if (cCardPostion == "B" && !colsBodyList.Contains(voucherIdFieldName.ToLower())) + { + colsBodyList.Add($"{cBWQName}.[{voucherIdFieldName.ToLower()}]"); + } } } @@ -1075,6 +1092,20 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 } } + if (cCardPostion == "L") + { + colsBodyList.AddRange(colsHeadList); + + if (bExtBody) + { + query.Select($"{string.Join(",",colsBodyList)}").Distinct(); + } + else + { + query.Select($"{string.Join(",", colsBodyList)}").Distinct(); + } + } + _logInfo.Debug(query.ToSqlString()); return new BaseResult() { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; diff --git a/UFIDA.U8.Framework.Api/Controllers/U8/SAController.cs b/UFIDA.U8.Framework.Api/Controllers/U8/SAController.cs index 0227bc8..3222314 100644 --- a/UFIDA.U8.Framework.Api/Controllers/U8/SAController.cs +++ b/UFIDA.U8.Framework.Api/Controllers/U8/SAController.cs @@ -146,5 +146,282 @@ namespace UFIDA.U8.Framework.Api.Controllers.U8 return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; } } + + /// + /// 查询特定单据部分 + /// + /// 系统号 + /// 单据类型编码 + /// 查询条件 + /// 查询所属区域 H:表头,B:表体 + /// + /// + [HttpPost] + [Route("api/U8/SA/{cCardNum}/Load")] + [Route("api/U8/SA/{cCardNum}/Load/{cCardPostion}")] + public async Task> Load(string cAccId, string cCardNum, [FromBody] Dictionary input, string cCardPostion = "H") + { + var workId = SnowFlakeSingle.Instance.NextId(); + + try + { + _logInfo.Debug($"作业Id:{workId}-----单据:{cCardNum},操作:查询,对接账套:{cAccId},条件:{input.ToJson()}"); + + if (!_cache.TryGetValue($"U8_{cAccId}", out BaseLogin baseLogin)) + { + _logInfo.Debug($"作业Id:{workId}-----未获取到缓存的登录信息,正在重新构建"); + + baseLogin = new BaseLogin(); + + var param = await CommUnit.GetLoginParamter(cAccId); + + if (param == null) + { + throw new Exception("未能加载指定系统号的登录信息"); + } + + baseLogin.Init(param, false); + + _cache.Clear(); + + _cache.Set($"U8_{cAccId}", baseLogin); + } + + var vouchers = CommonHelper.GetVouchers(baseLogin.Connection, cCardNum); + + if (vouchers == null) + { + throw new Exception("未能获取到单据配置信息"); + } + + var db = new SqlSugarClient(new ConnectionConfig() + { + DbType = DbType.SqlServer, + ConfigId = cAccId, + ConnectionString = baseLogin.UFDataConnstringForNet, + IsAutoCloseConnection = true, + MoreSettings = new ConnMoreSettings() + { + IsWithNoLockQuery = true + } + }); + + var cBTQName = vouchers.cBTQName; + var cBWQName = vouchers.cBWQName; + var cBTTblName = vouchers.cBTTblName; + var cBWTblName = vouchers.cBWTblName; + var voucherIdFieldName = vouchers.voucherIdFieldName; + var vouchersIdFieldName = ""; + var tableName = cBTQName; + var colsHeadList = new List(); + var colsBodyList = new List(); + var bExtHead = false; + var bExtBody = false; + + if (cCardPostion == "H") + { + tableName = cBTQName; + } + + if (cCardPostion == "B") + { + tableName = cBWQName; + } + + if (cCardPostion == "L") + { + tableName = cBWQName; + } + + var cDefWhere = vouchers.cDefWhere; + + var query = db.Queryable().AS(cBTQName, cBTQName); + + if (!string.IsNullOrWhiteSpace(cBWQName)) + { + query.AddJoinInfo(cBWQName, cBWQName, $"{cBTQName}.[{voucherIdFieldName}]={cBWQName}.[{voucherIdFieldName}]"); + + var bodyCols = db.DbMaintenance.GetColumnInfosByTableName(cBWQName); + + if (bodyCols != null && bodyCols.Count > 0) + { + colsBodyList.AddRange(from col in bodyCols where !col.DbColumnName.ToLower().Contains("ufts") && col.DbColumnName.ToLower() != voucherIdFieldName select $"{cBWQName}.[{col.DbColumnName.ToLower()}]"); + + if (cCardPostion == "B" && !colsBodyList.Contains(voucherIdFieldName.ToLower())) + { + colsBodyList.Add($"{cBWQName}.[{voucherIdFieldName.ToLower()}]"); + } + } + } + + var headCols = db.DbMaintenance.GetColumnInfosByTableName(cBTQName); + + if (headCols != null && headCols.Count > 0) + { + colsHeadList.AddRange(from col in headCols where !col.DbColumnName.ToLower().Contains("ufts") select $"{cBTQName}.[{col.DbColumnName}]"); + } + + if (db.DbMaintenance.IsAnyTable($"{cBTTblName}_extradefine", false)) + { + bExtHead = true; + var cols = db.DbMaintenance.GetColumnInfosByTableName($"{cBTTblName}_extradefine"); + + if (cols != null && cols.Count > 0) + { + foreach (var col in cols) + { + if (col.DbColumnName.ToLower().StartsWith("chdefine")) + { + colsHeadList.Add($"{cBTTblName}_extradefine.[{col.DbColumnName.ToLower()}]"); + } + else + { + vouchersIdFieldName = col.DbColumnName; + } + } + } + + query.AddJoinInfo($"{cBTTblName}_extradefine", $"{cBTTblName}_extradefine", $"{cBTQName}.[{voucherIdFieldName}]={cBTTblName}_extradefine.[{voucherIdFieldName}]"); + } + + if (db.DbMaintenance.IsAnyTable($"{cBWTblName}_extradefine", false)) + { + bExtBody = true; + var cols = db.DbMaintenance.GetColumnInfosByTableName($"{cBWTblName}_extradefine"); + + if (cols != null && cols.Count > 0) + { + foreach (var col in cols) + { + if (col.DbColumnName.ToLower().StartsWith("cbdefine")) + { + colsBodyList.Add($"{cBWTblName}_extradefine.[{col.DbColumnName.ToLower()}]"); + } + else + { + vouchersIdFieldName = col.DbColumnName; + } + } + } + + query.AddJoinInfo($"{cBWTblName}_extradefine", $"{cBWTblName}_extradefine", $"{cBWQName}.[{vouchersIdFieldName}]={cBWTblName}_extradefine.[{vouchersIdFieldName}]"); + } + + if (input != null) + { + var conModels = new List(); + + foreach (var o in input) + { + if (o.Key == "dModifyDate") + { + conModels.Add(new ConditionalModel + { + FieldName = "dverifysystime", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key == "dModifyDate__2") + { + conModels.Add(new ConditionalModel + { + FieldName = "dverifysystime", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if ($"{o.Value}".EndsWith("%") || $"{o.Value}".StartsWith("%")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.Like, + FieldValue = $"{o.Value}" + }); + } + else if (o.Key.EndsWith("__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key.Replace("__2", "")}", + ConditionalType = ConditionalType.LessThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else if (input.ContainsKey($"{o.Key}__2")) + { + conModels.Add(new ConditionalModel + { + FieldName = $"{o.Key}", + ConditionalType = ConditionalType.GreaterThanOrEqual, + FieldValue = $"{o.Value}" + }); + } + else + { + conModels.Add(new ConditionalModel + { + FieldName = o.Key, + ConditionalType = ConditionalType.Equal, + FieldValue = $"{o.Value}" + }); + } + } + + query.Where(conModels); + } + + query.Where(cDefWhere); + + if (cCardPostion == "H") + { + if (bExtHead) + { + query.Select($"{string.Join(",", colsHeadList)}").Distinct(); + } + else + { + query.Select($"{string.Join(",", colsHeadList)}").Distinct(); + } + } + + if (cCardPostion == "B") + { + if (bExtBody) + { + query.Select($"{string.Join(",", colsBodyList)}").Distinct(); + } + else + { + query.Select($"{string.Join(",", colsBodyList)}").Distinct(); + } + } + + if (cCardPostion == "L") + { + colsBodyList.AddRange(colsHeadList); + + if (bExtBody) + { + query.Select($"{string.Join(",", colsBodyList)}").Distinct(); + } + else + { + query.Select($"{string.Join(",", colsBodyList)}").Distinct(); + } + } + + _logInfo.Debug(query.ToSqlString()); + + return new BaseResult() { bSuccess = true, message = "查询成功", result = await query.ToListAsync() }; + } + catch (Exception ex) + { + _logInfo.Error(ex.Message, ex); + + return new BaseResult { bSuccess = false, message = ex.Message, result = ex.StackTrace }; + } + } } } diff --git a/UFIDA.U8.Framework.Api/UFIDA.U8.Framework.Api.csproj b/UFIDA.U8.Framework.Api/UFIDA.U8.Framework.Api.csproj index a17a2f6..c214ce9 100644 --- a/UFIDA.U8.Framework.Api/UFIDA.U8.Framework.Api.csproj +++ b/UFIDA.U8.Framework.Api/UFIDA.U8.Framework.Api.csproj @@ -445,6 +445,7 @@ PreserveNewest +