生成性能优化初版

parent 22e65d8d
...@@ -296,7 +296,7 @@ public ApiResponse PrejudgeLog([FromRoute] int allotId) ...@@ -296,7 +296,7 @@ public ApiResponse PrejudgeLog([FromRoute] int allotId)
var allot = allotService.GetAllot(allotId); var allot = allotService.GetAllot(allotId);
if (allot == null) if (allot == null)
return new ApiResponse(ResponseType.ParameterError, "AllotID错误"); return new ApiResponse(ResponseType.ParameterError, "AllotID错误");
var result=logService.GetLogDbug(allotId); var result = logService.GetLogDbug(allotId);
return new ApiResponse(ResponseType.OK, result); return new ApiResponse(ResponseType.OK, result);
} }
......
...@@ -10,35 +10,6 @@ ...@@ -10,35 +10,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <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" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
</ItemGroup> </ItemGroup>
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Dapper" Version="1.60.1" /> <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="Microsoft.EntityFrameworkCore" Version="2.2.0" />
<PackageReference Include="MySql.Data" Version="8.0.15" /> <PackageReference Include="MySql.Data" Version="8.0.15" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.15" /> <PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.15" />
......
...@@ -464,7 +464,6 @@ public void Generate(per_allot allot) ...@@ -464,7 +464,6 @@ public void Generate(per_allot allot)
catch (Exception ex) catch (Exception ex)
{ {
logManageService.WriteMsg("绩效生成失败", ex.Message, 4, allot.ID, "ReceiveMessage"); 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)); UpdateAllotStates(allot.ID, (int)AllotStates.GenerateFail, EnumHelper.GetDescription(AllotStates.GenerateFail));
//SendEmail(allot, mail, 2, time); //SendEmail(allot, mail, 2, time);
//throw ex; //throw ex;
......
...@@ -1207,8 +1207,8 @@ public void NewCopy(CopyRequest request) ...@@ -1207,8 +1207,8 @@ public void NewCopy(CopyRequest request)
/// <param name="allotId"></param> /// <param name="allotId"></param>
public void Clear(int allotId) public void Clear(int allotId)
{ {
var count = _directorRepository.DeleteData(allotId); _directorRepository.DeleteData(allotId);
logManageService.WriteMsg("清理无效数据", $"清理无效数据,受影响行数:{count}", 1, allotId, "ReceiveMessage", true); logManageService.WriteMsg("清理无效数据", $"清理无效数据", 1, allotId, "ReceiveMessage", true);
} }
/// <summary> /// <summary>
...@@ -1217,8 +1217,7 @@ public void Clear(int allotId) ...@@ -1217,8 +1217,7 @@ public void Clear(int allotId)
/// <param name="allotId"></param> /// <param name="allotId"></param>
public void ClearAllotData(int allotId) public void ClearAllotData(int allotId)
{ {
var count = _directorRepository.DeleteAllotData(allotId); _directorRepository.DeleteAllotData(allotId);
logManageService.WriteMsg("清理无效数据", $"清理无效数据,受影响行数:{count}", 1, allotId, "ReceiveMessage", true);
} }
/// <summary> /// <summary>
...@@ -1803,7 +1802,7 @@ public HandsonTable QueryHandsCustom(CustomPagingRequest request) ...@@ -1803,7 +1802,7 @@ public HandsonTable QueryHandsCustom(CustomPagingRequest request)
var result = new HandsonTable((int)SheetType.Unidentifiable, new string[] { }, new List<collect_permission>()); 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 data = JsonHelper.Deserialize<List<Dictionary<string, string>>>(jsonData);
var headDic = new List<Dictionary<string, object>>(); var headDic = new List<Dictionary<string, object>>();
...@@ -1873,7 +1872,7 @@ public ApiResponse SaveCustomTable(SaveCustomData request) ...@@ -1873,7 +1872,7 @@ public ApiResponse SaveCustomTable(SaveCustomData request)
var custom = perforReport.QueryCustomColumn(request.TableName); var custom = perforReport.QueryCustomColumn(request.TableName);
if(custom.Count>50) if (custom.Count > 50)
return new ApiResponse(ResponseType.ParameterError, "最多支持50列数据!"); return new ApiResponse(ResponseType.ParameterError, "最多支持50列数据!");
var dicCustom = new Dictionary<string, object>(); var dicCustom = new Dictionary<string, object>();
...@@ -1900,11 +1899,11 @@ public ApiResponse SaveCustomTable(SaveCustomData request) ...@@ -1900,11 +1899,11 @@ public ApiResponse SaveCustomTable(SaveCustomData request)
{ {
var type = ((IDictionary<string, object>)typeColumn.ElementAt(i)).Values.ElementAt(0).ToString(); var type = ((IDictionary<string, object>)typeColumn.ElementAt(i)).Values.ElementAt(0).ToString();
var itemDic = item.FirstOrDefault(t => t.Key.ToUpper() == type.ToUpper()); 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")) if (string.IsNullOrEmpty(itemDic.Value.ToString()) && value.Contains("date"))
item.AddOrUpdate(itemDic.Key,null); item.AddOrUpdate(itemDic.Key, null);
else if(!string.IsNullOrEmpty(itemDic.Value.ToString()) && value.Contains("date")) else if (!string.IsNullOrEmpty(itemDic.Value.ToString()) && value.Contains("date"))
{ {
try try
{ {
...@@ -1941,7 +1940,7 @@ public ApiResponse QueryCustom(CustomPagingRequest request) ...@@ -1941,7 +1940,7 @@ public ApiResponse QueryCustom(CustomPagingRequest request)
var isExist = perforReport.QueryIsAllotId(request.TableName); var isExist = perforReport.QueryIsAllotId(request.TableName);
if (isExist == false || heads == null) if (isExist == false || heads == null)
return new ApiResponse(ResponseType.ParameterError, "表不符合规范,请补全注释或修改重复注释"); return new ApiResponse(ResponseType.ParameterError, "表不符合规范,请补全注释或修改重复注释");
if(heads.Count>50) if (heads.Count > 50)
return new ApiResponse(ResponseType.ParameterError, "最多支持50列数据"); return new ApiResponse(ResponseType.ParameterError, "最多支持50列数据");
var headList = new List<Heads>(); var headList = new List<Heads>();
...@@ -1961,7 +1960,7 @@ public ApiResponse QueryCustom(CustomPagingRequest request) ...@@ -1961,7 +1960,7 @@ public ApiResponse QueryCustom(CustomPagingRequest request)
return new ApiResponse(ResponseType.ParameterError, "表不符合规范,请补全注释或修改重复注释"); return new ApiResponse(ResponseType.ParameterError, "表不符合规范,请补全注释或修改重复注释");
result.Heads = headList; result.Heads = headList;
result.Datas = perforReport.QueryCustom(request,false); result.Datas = perforReport.QueryCustom(request, false);
return new ApiResponse(ResponseType.OK, result); 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.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using MySql.Data.MySqlClient;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.DtoModels.AppSettings; using Performance.DtoModels.AppSettings;
using Performance.EntityModels; using Performance.EntityModels;
...@@ -8,6 +11,8 @@ ...@@ -8,6 +11,8 @@
using Performance.Repository; using Performance.Repository;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Performance.Services namespace Performance.Services
...@@ -16,19 +21,19 @@ public class LogManageService : IAutoInjection ...@@ -16,19 +21,19 @@ public class LogManageService : IAutoInjection
{ {
private readonly ILogger<LogManageService> logger; private readonly ILogger<LogManageService> logger;
private readonly IHubContext<AllotLogHub> hubContext; private readonly IHubContext<AllotLogHub> hubContext;
private readonly IOptions<AppConnection> _options;
private readonly WebapiUrl url; private readonly WebapiUrl url;
private PerforLogdbugRepository logdbug;
public LogManageService( public LogManageService(
ILogger<LogManageService> logger, ILogger<LogManageService> logger,
IHubContext<AllotLogHub> hubContext, IHubContext<AllotLogHub> hubContext,
IOptions<WebapiUrl> url, IOptions<WebapiUrl> url,
PerforLogdbugRepository logdbug) IOptions<AppConnection> options)
{ {
this.logger = logger; this.logger = logger;
this.hubContext = hubContext; this.hubContext = hubContext;
_options = options;
this.url = url.Value; this.url = url.Value;
this.logdbug = logdbug;
} }
/// <summary> /// <summary>
...@@ -45,7 +50,15 @@ public void WriteMsg(string tag, string message, int level, int allotId, string ...@@ -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); hubContext.Clients.Group(allotId.ToString()).SendAsync(method, tag, message, level);
if (isDebug) 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 ...@@ -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); 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) if (!isSingle)
{ {
var http = new RestSharpHelper(); var http = new RestSharpHelper();
...@@ -128,15 +141,22 @@ public void ReturnTheLog(int allotId, string groupName, int type, string tag, ob ...@@ -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信息展示 //todo:log信息展示
public List<log_dbug> GetLogDbug(int allotId) 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