打印模块查询问题处理

dev
cjy 2 months ago
parent 0a70e89391
commit 13ff64f8b3

2
.gitignore vendored

@ -81,3 +81,5 @@ LinkAttach
/ds-wms-service/DS.WMS.MainApi/wwwroot/LinkAttach/1800840199861833728.png /ds-wms-service/DS.WMS.MainApi/wwwroot/LinkAttach/1800840199861833728.png
/ds-wms-service/DS.WMS.MainApi/wwwroot/LinkAttach/1800846562843299840.txt /ds-wms-service/DS.WMS.MainApi/wwwroot/LinkAttach/1800846562843299840.txt
/ds-wms-service/DS.WMS.CheckApi/Logs/internal-nlog.txt /ds-wms-service/DS.WMS.CheckApi/Logs/internal-nlog.txt
/ds-wms-service/DS.WMS.FinanceApi/.config/dotnet-tools.json
/ds-wms-service/DS.WMS.FinanceApi/Properties/PublishProfiles/FolderProfile.pubxml

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<DeleteExistingFiles>false</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>D:\Code\PublishCopy\ds8-financeapi</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
</PropertyGroup>
</Project>

@ -18,7 +18,7 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.2.7" /> <PackageReference Include="NLog" Version="5.2.7" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.166" /> <PackageReference Include="SqlSugarCore" Version="5.1.4.169" />
<PackageReference Include="Autofac" Version="6.4.0" /> <PackageReference Include="Autofac" Version="6.4.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" /> <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />

@ -88,23 +88,7 @@ namespace DS.WMS.PrintApi.Middleware
Console.WriteLine("configId" + Environment.NewLine + configId); Console.WriteLine("configId" + Environment.NewLine + configId);
//sqlStr = sqlStr.Replace('[', ' ').Replace(']', ' '); //sqlStr = sqlStr.Replace('[', ' ').Replace(']', ' ');
Console.WriteLine("执行的SQL" + Environment.NewLine + sqlStr); Console.WriteLine("执行的SQL" + Environment.NewLine + sqlStr);
}; };
//数据处理事件
dbProvider.Aop.OnExecutingChangeSql = (sql, pars) => //可以修改SQL和参数的值
{
//sql = sql.Replace('[', ' ').Replace(']', ' ');
//sql=newsql
foreach (var p in pars) //修改
{
if (p.Value.ToString().Contains("["))
{
var temp = JsonConvert.DeserializeObject<List<string>>(p.Value.ToString());
p.Value = string.Join(", ", temp);
}
//p.Value = p.Value.ToString().Replace('[', ' ').Replace(']', ' ').Replace('&', ',');
}
return new KeyValuePair<string, SugarParameter[]>(sql, pars);
};
//数据处理事件 //数据处理事件
dbProvider.Aop.DataExecuting = (oldValue, entityInfo) => dbProvider.Aop.DataExecuting = (oldValue, entityInfo) =>
{ {
@ -113,9 +97,7 @@ namespace DS.WMS.PrintApi.Middleware
dbProvider.Aop.OnLogExecuted = (sql, pars) => dbProvider.Aop.OnLogExecuted = (sql, pars) =>
{ {
//执行完了可以输出SQL执行时间 (OnLogExecutedDelegate) //执行完了可以输出SQL执行时间 (OnLogExecutedDelegate)
Console.Write("time:" + db.Ado.SqlExecutionTime.ToString()); Console.Write("time:" + db.Ado.SqlExecutionTime.ToString());
Console.Write("time:" + db.Ado.Connection.ConnectionString);
Console.Write("time:" + db.Ado.SqlStackTrace.SugarStackTraceList);
}; };
dbProvider.Aop.OnDiffLogEvent = it => dbProvider.Aop.OnDiffLogEvent = it =>
{ {

@ -16,6 +16,9 @@ using Microsoft.Extensions.DependencyInjection;
using DS.WMS.PrintApi.Middleware; using DS.WMS.PrintApi.Middleware;
using Newtonsoft.Json.Schema; using Newtonsoft.Json.Schema;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Data;
using System.Dynamic;
namespace DS.WMS.PrintApi.Service namespace DS.WMS.PrintApi.Service
{ {
@ -346,8 +349,18 @@ namespace DS.WMS.PrintApi.Service
{ {
var param = JsonHelper.Instance.Deserialize<Dictionary<string, dynamic>>(req.ParamJsonStr); var param = JsonHelper.Instance.Deserialize<Dictionary<string, dynamic>>(req.ParamJsonStr);
foreach (var p in param) foreach (var p in param)
{ {
sugarParams.Add(new SugarParameter($"@{p.Key}", p.Value)); if (p.Key == "ids")
{
var temp = JsonConvert.DeserializeObject<List<string>>(p.Value.ToString());
sugarParams.Add(new SugarParameter($"@{p.Key}", temp.ToArray()));
}
else
{
sugarParams.Add(new SugarParameter($"@{p.Key}", p.Value));
}
} }
} }
@ -361,7 +374,7 @@ namespace DS.WMS.PrintApi.Service
if (!string.IsNullOrEmpty(sqlArr[i])) if (!string.IsNullOrEmpty(sqlArr[i]))
{ {
var temp = tenantDb.Ado.SqlQuery<dynamic>(sqlArr[i], sugarParams); var temp = tenantDb.Ado.SqlQuery<dynamic>(sqlArr[i], sugarParams);
data.Add("sql" + i, temp); data.Add("sql" + i, temp);
} }
} }
@ -487,7 +500,7 @@ namespace DS.WMS.PrintApi.Service
//Logger.Warn(ex, "方法: GetOpenJsonPrintInfo"); //Logger.Warn(ex, "方法: GetOpenJsonPrintInfo");
return await Task.FromResult(PrintDataResult.Failed(ex.Message)); return await Task.FromResult(PrintDataResult.Failed(ex.Message));
} }
} }
/// <summary> /// <summary>
/// 下载sql打印frx文件 /// 下载sql打印frx文件
@ -547,7 +560,17 @@ namespace DS.WMS.PrintApi.Service
var param = JsonHelper.Instance.Deserialize<Dictionary<string, dynamic>>(req.ParamJsonStr); var param = JsonHelper.Instance.Deserialize<Dictionary<string, dynamic>>(req.ParamJsonStr);
foreach (var p in param) foreach (var p in param)
{ {
sugarParams.Add(new SugarParameter($"@{p.Key}", p.Value)); //sugarParams.Add(new SugarParameter($"@{p.Key}", p.Value));
if (p.Key == "ids")
{
var temp = JsonConvert.DeserializeObject<List<string>>(p.Value.ToString());
sugarParams.Add(new SugarParameter($"@{p.Key}", temp.ToArray()));
}
else
{
sugarParams.Add(new SugarParameter($"@{p.Key}", p.Value));
}
} }
} }

Loading…
Cancel
Save