生成性能优化初版

parent 22e65d8d
......@@ -296,7 +296,7 @@ public ApiResponse PrejudgeLog([FromRoute] int allotId)
var allot = allotService.GetAllot(allotId);
if (allot == null)
return new ApiResponse(ResponseType.ParameterError, "AllotID错误");
var result=logService.GetLogDbug(allotId);
var result = logService.GetLogDbug(allotId);
return new ApiResponse(ResponseType.OK, result);
}
......
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>..\Performance.Api\wwwroot\Performance.EntityModels.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Remove="T4Template\**" />
<EmbeddedResource Remove="T4Template\**" />
<None Remove="T4Template\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Entity\dis_drugatc.Generated.cs" />
<Compile Remove="Entity\dis_drug_tree.Generated.cs" />
<Compile Remove="Entity\dis_drug_type.Generated.cs" />
<Compile Remove="Entity\dis_drug_useinfo_fee.Generated.cs" />
<Compile Remove="Entity\dis_ip_fee.Generated.cs" />
<Compile Remove="Entity\dis_use_drugs.Generated.cs" />
<Compile Remove="Entity\drug_department_useinfo.Generated.cs" />
<Compile Remove="Entity\drug_dosage.Generated.cs" />
<Compile Remove="Entity\drug_first_use.Generated.cs" />
<Compile Remove="Entity\drug_hosinfo.Generated.cs" />
<Compile Remove="Entity\drug_p_info.Generated.cs" />
<Compile Remove="Entity\drug_p_mi.Generated.cs" />
<Compile Remove="Entity\drug_p_userinfo.Generated.cs" />
<Compile Remove="Entity\drug_som.Generated.cs" />
<Compile Remove="Entity\hos_department_coc.Generated.cs" />
<Compile Remove="Entity\hos_department_fee.Generated.cs" />
<Compile Remove="Entity\hos_disease_person.Generated.cs" />
<Compile Remove="Entity\hos_drugatc.Generated.cs" />
<Compile Remove="Entity\hos_drug_fee.Generated.cs" />
<Compile Remove="Entity\hos_drug_type.Generated.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<ItemGroup>
<Compile Update="T4\AutoContext.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>AutoContext.tt</DependentUpon>
</Compile>
<Compile Update="T4\AutoEntity.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>AutoEntity.tt</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="T4\AutoContext.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AutoContext.cs</LastGenOutput>
</None>
<None Update="T4\AutoEntity.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AutoEntity.cs</LastGenOutput>
</None>
</ItemGroup>
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>..\Performance.Api\wwwroot\Performance.EntityModels.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<ItemGroup>
<Compile Update="T4\AutoContext.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>AutoContext.tt</DependentUpon>
</Compile>
<Compile Update="T4\AutoEntity.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>AutoEntity.tt</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="T4\AutoContext.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AutoContext.cs</LastGenOutput>
</None>
<None Update="T4\AutoEntity.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AutoEntity.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="1.60.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
<PackageReference Include="MySql.Data" Version="8.0.15" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.15" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="2.19.60" />
<PackageReference Include="Z.EntityFramework.Extensions.EFCore" Version="2.8.40" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="1.60.1" />
<PackageReference Include="Dapper.Contrib" Version="1.60.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
<PackageReference Include="MySql.Data" Version="8.0.15" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.15" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="2.19.60" />
<PackageReference Include="Z.EntityFramework.Extensions.EFCore" Version="2.8.40" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Performance.DtoModels\Performance.DtoModels.csproj" />
<ProjectReference Include="..\Performance.EntityModels\Performance.EntityModels.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Performance.DtoModels\Performance.DtoModels.csproj" />
<ProjectReference Include="..\Performance.EntityModels\Performance.EntityModels.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="T4\AutoRepository.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AutoRepository.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Update="T4\AutoRepository.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AutoRepository.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
<ItemGroup>
<Compile Update="T4\AutoRepository.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>AutoRepository.tt</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Update="T4\AutoRepository.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>AutoRepository.tt</DependentUpon>
</Compile>
</ItemGroup>
</Project>
......@@ -464,7 +464,6 @@ public void Generate(per_allot allot)
catch (Exception ex)
{
logManageService.WriteMsg("绩效生成失败", ex.Message, 4, allot.ID, "ReceiveMessage");
logdbug.Add(allot.ID, "绩效生成失败", ex.ToString(), 4, 1);
UpdateAllotStates(allot.ID, (int)AllotStates.GenerateFail, EnumHelper.GetDescription(AllotStates.GenerateFail));
//SendEmail(allot, mail, 2, time);
//throw ex;
......
......@@ -1207,8 +1207,8 @@ public void NewCopy(CopyRequest request)
/// <param name="allotId"></param>
public void Clear(int allotId)
{
var count = _directorRepository.DeleteData(allotId);
logManageService.WriteMsg("清理无效数据", $"清理无效数据,受影响行数:{count}", 1, allotId, "ReceiveMessage", true);
_directorRepository.DeleteData(allotId);
logManageService.WriteMsg("清理无效数据", $"清理无效数据", 1, allotId, "ReceiveMessage", true);
}
/// <summary>
......@@ -1217,8 +1217,7 @@ public void Clear(int allotId)
/// <param name="allotId"></param>
public void ClearAllotData(int allotId)
{
var count = _directorRepository.DeleteAllotData(allotId);
logManageService.WriteMsg("清理无效数据", $"清理无效数据,受影响行数:{count}", 1, allotId, "ReceiveMessage", true);
_directorRepository.DeleteAllotData(allotId);
}
/// <summary>
......@@ -1803,7 +1802,7 @@ public HandsonTable QueryHandsCustom(CustomPagingRequest request)
var result = new HandsonTable((int)SheetType.Unidentifiable, new string[] { }, new List<collect_permission>());
var jsonData = JsonHelper.Serialize(perforReport.QueryCustom(request,true).DataList);
var jsonData = JsonHelper.Serialize(perforReport.QueryCustom(request, true).DataList);
var data = JsonHelper.Deserialize<List<Dictionary<string, string>>>(jsonData);
var headDic = new List<Dictionary<string, object>>();
......@@ -1873,7 +1872,7 @@ public ApiResponse SaveCustomTable(SaveCustomData request)
var custom = perforReport.QueryCustomColumn(request.TableName);
if(custom.Count>50)
if (custom.Count > 50)
return new ApiResponse(ResponseType.ParameterError, "最多支持50列数据!");
var dicCustom = new Dictionary<string, object>();
......@@ -1900,11 +1899,11 @@ public ApiResponse SaveCustomTable(SaveCustomData request)
{
var type = ((IDictionary<string, object>)typeColumn.ElementAt(i)).Values.ElementAt(0).ToString();
var itemDic = item.FirstOrDefault(t => t.Key.ToUpper() == type.ToUpper());
var value=((IDictionary<string, object>)typeColumn.ElementAt(i)).Values.ElementAt(1).ToString();
var value = ((IDictionary<string, object>)typeColumn.ElementAt(i)).Values.ElementAt(1).ToString();
if (string.IsNullOrEmpty(itemDic.Value.ToString()) && value.Contains("date"))
item.AddOrUpdate(itemDic.Key,null);
else if(!string.IsNullOrEmpty(itemDic.Value.ToString()) && value.Contains("date"))
item.AddOrUpdate(itemDic.Key, null);
else if (!string.IsNullOrEmpty(itemDic.Value.ToString()) && value.Contains("date"))
{
try
{
......@@ -1914,7 +1913,7 @@ public ApiResponse SaveCustomTable(SaveCustomData request)
{
return new ApiResponse(ResponseType.ParameterError, "请输入正确的日期格式");
}
}
......@@ -1941,7 +1940,7 @@ public ApiResponse QueryCustom(CustomPagingRequest request)
var isExist = perforReport.QueryIsAllotId(request.TableName);
if (isExist == false || heads == null)
return new ApiResponse(ResponseType.ParameterError, "表不符合规范,请补全注释或修改重复注释");
if(heads.Count>50)
if (heads.Count > 50)
return new ApiResponse(ResponseType.ParameterError, "最多支持50列数据");
var headList = new List<Heads>();
......@@ -1961,7 +1960,7 @@ public ApiResponse QueryCustom(CustomPagingRequest request)
return new ApiResponse(ResponseType.ParameterError, "表不符合规范,请补全注释或修改重复注释");
result.Heads = headList;
result.Datas = perforReport.QueryCustom(request,false);
result.Datas = perforReport.QueryCustom(request, false);
return new ApiResponse(ResponseType.OK, result);
}
......
using Microsoft.AspNetCore.SignalR;
using Dapper;
using Dapper.Contrib.Extensions;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using MySql.Data.MySqlClient;
using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.EntityModels;
......@@ -8,6 +11,8 @@
using Performance.Repository;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
namespace Performance.Services
......@@ -16,19 +21,19 @@ public class LogManageService : IAutoInjection
{
private readonly ILogger<LogManageService> logger;
private readonly IHubContext<AllotLogHub> hubContext;
private readonly IOptions<AppConnection> _options;
private readonly WebapiUrl url;
private PerforLogdbugRepository logdbug;
public LogManageService(
ILogger<LogManageService> logger,
IHubContext<AllotLogHub> hubContext,
IOptions<WebapiUrl> url,
PerforLogdbugRepository logdbug)
IOptions<AppConnection> options)
{
this.logger = logger;
this.hubContext = hubContext;
_options = options;
this.url = url.Value;
this.logdbug = logdbug;
}
/// <summary>
......@@ -45,7 +50,15 @@ public void WriteMsg(string tag, string message, int level, int allotId, string
hubContext.Clients.Group(allotId.ToString()).SendAsync(method, tag, message, level);
if (isDebug)
{
logdbug.Add(allotId, tag, message, level, 1);
Insert(allotId, tag, message, level, 1);
}
}
private void Insert(int allotId, string tag, string message, int level, int type)
{
using (IDbConnection connection = new MySqlConnection(_options.Value.PerformanceConnectionString))
{
connection.Insert<log_dbug>(new log_dbug { AllotID = allotId, CreateTime = DateTime.Now, Title = tag, Message = message, Level = level, Type = type });
}
}
......@@ -103,7 +116,7 @@ public void ReturnTheLog(int allotId, string groupName, int type, string tag, ob
if (isSingle) hubContext.Clients.Group(groupName).SendAsync("Schedule", ratio, level);
}
logdbug.Add(allotId, tag, content, level, type);
Insert(allotId, tag, content, level, type);
if (!isSingle)
{
var http = new RestSharpHelper();
......@@ -128,15 +141,22 @@ public void ReturnTheLog(int allotId, string groupName, int type, string tag, ob
}
}
public bool ClearExtractLog(int allotId)
public int ClearExtractLog(int allotId)
{
return logdbug.ClearExtractLog(allotId);
using (IDbConnection connection = new MySqlConnection(_options.Value.PerformanceConnectionString))
{
return connection.Execute("delete from log_dbug where AllotID = @allotId and Type in @type", new { allotId, type = new int[] { 2, 3 } });
}
}
//todo:log信息展示
public List<log_dbug> GetLogDbug(int allotId)
{
return logdbug.GetEntities(t => t.AllotID == allotId && t.Type==2);
using (IDbConnection connection = new MySqlConnection(_options.Value.PerformanceConnectionString))
{
var logs = connection.Query<log_dbug>("select * from log_dbug where AllotID = @allotId and Type = @type", new { allotId, type = 2 });
return logs == null || logs.Count() == 0 ? new List<log_dbug>() : logs.ToList();
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment