Commit c91751fb by ruyun.zhang@suvalue.com

Merge branch 'release/v20210514'

parents c4c527db 2de004d6
...@@ -28,42 +28,93 @@ public class SubsidyController : ControllerBase ...@@ -28,42 +28,93 @@ public class SubsidyController : ControllerBase
public async Task<ApiResponse> GetAllot() public async Task<ApiResponse> GetAllot()
{ {
var allots = await _service.GetAllot(); var allots = await _service.GetAllot();
return new ApiResponse(Status.Ok, allots); return new ApiResponse(Status.Ok, allots);
} }
// 职称查询 /// <summary>
[HttpGet("{allotId}/jobtitle")] /// 职称查询
public async Task<ApiResponse> GetJobTitle(int allotId) /// </summary>
/// <param name="allotId"></param>
/// <param name="hospitalId"></param>
/// <returns></returns>
[HttpGet("{allotId}/jobtitle/{hospitalId}")]
public ApiResponse GetJobTitle(int allotId, int hospitalId)
{ {
throw new NotImplementedException(); _service.GetHrpJobTitle(allotId, hospitalId, false);
var jobTitle = _service.GetJobTitle(allotId, hospitalId);
return new ApiResponse(Status.Ok, jobTitle);
} }
// 重新查询职称 /// <summary>
[HttpPost("{allotId}/reset-jobtitle")] /// 重新查询职称
public async Task ResetJobTitle(int allotId) /// </summary>
/// <param name="allotId"></param>
/// <param name="hospitalId"></param>
/// <returns></returns>
[HttpPost("{allotId}/reset-jobtitle/{hospitalId}")]
public ApiResponse ResetJobTitle(int allotId, int hospitalId)
{ {
throw new NotImplementedException(); // 调取配置的SQL语句
// 执行SQL 获取结果
// 将结果存储到sub_subsidy中
// 查询sub_subsidy表职称去重
// 将去重数据插入sub_jobtitle
_service.GetHrpJobTitle(allotId, hospitalId, true);
var jobTitle = _service.GetJobTitle(allotId, hospitalId);
return new ApiResponse(Status.Ok, jobTitle);
} }
// 职称标准保存 /// <summary>
/// 职称标准保存
/// </summary>
/// <param name="allotId"></param>
/// <param name="sub_Jobtitle"></param>
/// <returns></returns>
[HttpPost("{allotId}/jobtitle")] [HttpPost("{allotId}/jobtitle")]
public async Task SaveJobTitle(int allotId) public ApiResponse SaveJobTitle(int allotId, [FromBody] List<sub_jobtitle> sub_Jobtitle)
{ {
throw new NotImplementedException(); bool result = _service.SaveJobTitle(allotId, sub_Jobtitle);
return new ApiResponse(Status.Ok, result);
} }
// 个人职称补贴结果查询 /// <summary>
/// 个人职称补贴结果查询
/// </summary>
/// <param name="allotId"></param>
/// <returns></returns>
[HttpGet("{allotId}/jobtitle/subsidy")] [HttpGet("{allotId}/jobtitle/subsidy")]
public Task<ApiResponse> GetJobTitleSubsidy(int allotId) public ApiResponse GetJobTitleSubsidy(int allotId)
{ {
throw new NotImplementedException(); List<sub_subsidy> subsidies = _service.GetJobTitleSubsidy(allotId);
return new ApiResponse(Status.Ok, subsidies);
} }
// 个人职称补贴结果保存 /// <summary>
/// 个人职称补贴结果保存
/// </summary>
/// <param name="allotId"></param>
/// <param name="subsidys"></param>
/// <returns></returns>
[HttpPost("{allotId}/jobtitle/subsidy")] [HttpPost("{allotId}/jobtitle/subsidy")]
public async Task SaveJobTitleSubsidy(int allotId) public ApiResponse SaveJobTitleSubsidy(int allotId, [FromBody] List<sub_subsidy> subsidys)
{
bool result = _service.SaveJobTitleSubsidy(allotId, subsidys);
return new ApiResponse(Status.Ok, result);
}
/// <summary>
/// 保存个人职称补贴结果
/// </summary>
/// <param name="allotId"></param>
/// <param name="subsidies"></param>
/// <returns></returns>
[HttpPost("{allotId}/savesubsidy")]
public ApiResponse SaveSubsidy(int allotId,[FromBody] List<sub_subsidy> subsidies)
{ {
throw new NotImplementedException(); var result = _service.SaveSubsidy(allotId, subsidies);
return new ApiResponse(Status.Ok, result);
} }
} }
} }
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Performance.Subsidy.Api.Filters
{
public class ExceptionsFilter : IAsyncExceptionFilter
{
private readonly ILogger<ExceptionsFilter> _logger;
public ExceptionsFilter(ILogger<ExceptionsFilter> logger)
{
this._logger = logger;
}
public Task OnExceptionAsync(ExceptionContext context)
{
if(context.Exception is Exception)
{
_logger.LogError($"接口异常:{context.Exception.ToString()}");
var response = new ApiResponse(Status.Error, "接口内部异常", context.Exception.Message);
context.Result = new ObjectResult(response);
_logger.LogError("接口内部异常" + JsonConvert.SerializeObject(response, Formatting.None));
}
return Task.CompletedTask;
}
}
}
...@@ -5,6 +5,13 @@ ...@@ -5,6 +5,13 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NLog" Version="4.7.9" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.4.0" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.8.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="Autofac" Version="6.2.0" /> <PackageReference Include="Autofac" Version="6.2.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NLog.Web;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -14,7 +15,19 @@ public class Program ...@@ -14,7 +15,19 @@ public class Program
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
CreateHostBuilder(args).Build().Run(); var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
try
{
CreateHostBuilder(args).Build().Run();
}
catch (Exception ex)
{
logger.Error(ex, "Stopped program because of exception");
}
finally
{
NLog.LogManager.Shutdown();
}
} }
public static IHostBuilder CreateHostBuilder(string[] args) => public static IHostBuilder CreateHostBuilder(string[] args) =>
...@@ -23,6 +36,12 @@ public static void Main(string[] args) ...@@ -23,6 +36,12 @@ public static void Main(string[] args)
.ConfigureWebHostDefaults(webBuilder => .ConfigureWebHostDefaults(webBuilder =>
{ {
webBuilder.UseStartup<Startup>(); webBuilder.UseStartup<Startup>();
}); })
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.SetMinimumLevel(LogLevel.Trace);
})
.UseNLog();
} }
} }
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DeleteExistingFiles>False</DeleteExistingFiles>
<ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>D:\publish\Subsidy</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
</PropertyGroup>
</Project>
\ No newline at end of file
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;
using Performance.Subsidy.Api.Filters;
using Performance.Subsidy.Services; using Performance.Subsidy.Services;
using Performance.Subsidy.Services.Models; using Performance.Subsidy.Services.Models;
using Performance.Subsidy.Services.Repository; using Performance.Subsidy.Services.Repository;
...@@ -38,18 +39,23 @@ public void ConfigureServices(IServiceCollection services) ...@@ -38,18 +39,23 @@ public void ConfigureServices(IServiceCollection services)
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Performance.Subsidy.Api", Version = "v1" }); c.SwaggerDoc("v1", new OpenApiInfo { Title = "Performance.Subsidy.Api", Version = "v1" });
}); });
services.Configure<ConnectionStringTemplates>(Configuration.GetSection("ConnectionStringTemplates")); services.Configure<ConnectionStringTemplates>(Configuration.GetSection("ConnectionStringTemplates"));
services.AddMvc(option => { option.Filters.Add<ExceptionsFilter>(); });
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{ {
string swaggerJson = "/api/swagger/v1/swagger.json";
if (env.IsDevelopment()) if (env.IsDevelopment())
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
app.UseSwagger(); swaggerJson = swaggerJson.Replace("/api", "");
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Performance.Subsidy.Api v1"));
} }
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint(swaggerJson, "Performance.Subsidy.Api v1"));
app.UseRouting(); app.UseRouting();
app.UseAuthorization(); app.UseAuthorization();
......
<?xml version="1.0" encoding="utf-8"?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="info"
internalLogFile="c:\Temp\GrapefruitVuCore\internal-nlog.txt">
<!-- enable asp.net core and mongodb layout renderers -->
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
<add assembly="NLog.Mongo"/>
</extensions>
<!--internal-nlog:NLog启动及加载config信息-->
<!--nlog-all:所有日志记录信息-->
<!--nlog-own:自定义日志记录信息-->
<!-- the targets to write to -->
<targets>
<!-- write logs to file -->
<target xsi:type="File" name="allfile" fileName="${basedir}/Logs/${shortdate}/${level}.log"
layout="日志记录时间:${longdate}${newline}日志级别:${uppercase:${level}}${newline}日志来源:${logger}${newline}日志信息:${message}${newline}错误信息:${exception:format=tostring}${newline}==============================================================${newline}" />
<!-- another file log, only own logs. Uses some ASP.NET core renderers -->
<target xsi:type="File" name="ownFile-web" fileName="${basedir}/Logs/${shortdate}/${level}.log"
layout="日志记录时间:${longdate}${newline}日志级别:${uppercase:${level}}${newline}日志来源:${logger}${newline}日志信息:${message}${newline}错误信息:${exception:format=tostring}${newline}url: ${aspnet-request-url}${newline}action: ${aspnet-mvc-action}${newline}==============================================================${newline}" />
</targets>
<!-- rules to map from logger name to target -->
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Trace" writeTo="allfile" />
<!--Skip non-critical Microsoft logs and so log only own logs-->
<logger name="Microsoft.*" maxLevel="Info" final="true" />
<!-- BlackHole without writeTo -->
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
<!--Add logs to mongodb-->
<!--<logger name="*" minlevel="Trace" writeTo="mongo"/>-->
</rules>
</nlog>
\ No newline at end of file
...@@ -13,8 +13,8 @@ public enum Status ...@@ -13,8 +13,8 @@ public enum Status
public enum DatabaseType public enum DatabaseType
{ {
MySQL, MySQL=1,
SqlServer, SqlServer=2,
Oracle, Oracle=3,
} }
} }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Subsidy.Services
{
public class ex_config
{
public int Id { get; set; }
public int HospitalId { get; set; }
public string DbSource { get; set; }
public string DbName { get; set; }
public string DbUser { get; set; }
public string DbPassword { get; set; }
public int DataBaseType { get; set; }
public string Remark { get; set; }
}
}
namespace Performance.Subsidy.Services namespace Performance.Subsidy.Services
{ {
public class ex_script { } public class ex_script
{
public int Id { get; set; }
public string ExecScript { get; set; }
public int ConfigId { get; set; }
public int IsEnable { get; set; }
public string Remark { get; set; }
}
} }
...@@ -5,6 +5,6 @@ public class sub_jobtitle ...@@ -5,6 +5,6 @@ public class sub_jobtitle
public int ID { get; set; } public int ID { get; set; }
public int AllotId { get; set; } public int AllotId { get; set; }
public string JobTitle { get; set; } public string JobTitle { get; set; }
public decimal? BasicPerforFee { get; set; } public decimal? BasicPerforFee { get; set; }
} }
} }
...@@ -6,8 +6,12 @@ ...@@ -6,8 +6,12 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Dapper" Version="2.0.90" /> <PackageReference Include="Dapper" Version="2.0.90" />
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.7" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
<PackageReference Include="MySql.Data" Version="8.0.24" /> <PackageReference Include="MySql.Data" Version="8.0.24" />
<PackageReference Include="NLog" Version="4.7.9" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.1" /> <PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.1" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" /> <PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
</ItemGroup> </ItemGroup>
......
using Dapper; using Dapper;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging;
using Performance.Subsidy.Services.Repository; using Performance.Subsidy.Services.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.Subsidy.Services namespace Performance.Subsidy.Services
...@@ -10,23 +12,194 @@ namespace Performance.Subsidy.Services ...@@ -10,23 +12,194 @@ namespace Performance.Subsidy.Services
public class SubsidyService public class SubsidyService
{ {
private readonly ConnectionFactory _factory; private readonly ConnectionFactory _factory;
private readonly ConnectionStringBuilder builder;
private readonly int _commandTimeout; private readonly int _commandTimeout;
private readonly IDbConnection _dbConnection;
private readonly ILogger<SubsidyService> logger;
public SubsidyService( public SubsidyService(
ConnectionFactory factory) ConnectionFactory factory,
ConnectionStringBuilder builder,
ILogger<SubsidyService> logger)
{ {
_factory = factory; _factory = factory;
this.builder = builder;
_commandTimeout = 60 * 5; _commandTimeout = 60 * 5;
_dbConnection = _factory.CreateDefault();
this.logger = logger;
} }
//绩效列表
public async Task<IEnumerable<view_allot>> GetAllot() public async Task<IEnumerable<view_allot>> GetAllot()
{ {
return await _factory.CreateDefault().QueryAsync<view_allot>("SELECT * FROM view_allot"); return await _dbConnection.QueryAsync<view_allot>("SELECT * FROM view_allot;");
} }
public async Task<IEnumerable<sub_jobtitle>> GetJobTitle(int allotId) //allot查询
public view_allot GetAllot(int allotId)
{ {
return await _factory.CreateDefault().QueryAsync<sub_jobtitle>("SELECT * FROM sub_jobtitle WHERE AllotID=@allotId", new { allotId }); return _dbConnection.QueryFirst<view_allot>($@"select * from view_allot where AllotID=@allotId;", new { allotId });
}
//职称查询
public IEnumerable<sub_jobtitle> GetJobTitle(int allotId, int hospitalId)
{
try
{
var jobTitleSql = $@"select * from sub_jobtitle where AllotID=@allotId ";
var jobTitles = _dbConnection.Query<sub_jobtitle>(jobTitleSql, new { allotId });
if (jobTitles?.Count() > 0) return jobTitles;
jobTitles = _dbConnection.Query<sub_jobtitle>($@"SELECT DISTINCT JobTitle FROM db_performance_subsidy.sub_subsidy where AllotID=@allotId ", new { allotId }).Select(t => new sub_jobtitle { JobTitle = t.JobTitle, BasicPerforFee = t.BasicPerforFee ?? 0 });
var allotOder = _dbConnection.Query<view_allot>($@"SELECT * from view_allot a WHERE a.HospitalId=@HospitalId ORDER BY a.`Year`,a.`Month`;", new { hospitalId }).ToList();
if (!allotOder.Any()) return jobTitles;
var allot = allotOder.FirstOrDefault(t => t.AllotId == allotId);
if (allot == null) throw new Exception("有问题");
var index = allotOder.IndexOf(allot);
if (index == 0) return jobTitles;
var prevAllot = allotOder[index - 1];
var jobTitle = _dbConnection.Query<sub_jobtitle>(jobTitleSql, new { prevAllot.AllotId });
return jobTitle.Select(t => new sub_jobtitle { JobTitle = t.JobTitle, BasicPerforFee = t.BasicPerforFee ?? 0 }) ?? jobTitles;
}
catch (Exception e)
{
logger.LogError(e.Message);
throw e;
}
}
//重新查询职称
public void GetHrpJobTitle(int allotId, int hospitalId, bool isRefresh)
{
try
{
var allot = GetAllot(allotId);
if (allot == null) throw new Exception("AllotId无效");
var subsidies = _dbConnection.Query<sub_subsidy>("select * from sub_subsidy where AllotID=@allotId ", new { allotId });
if (subsidies.Any() && isRefresh == false) return;
var config = _dbConnection.QueryFirst<ex_config>("select * from ex_config where hospitalId=@hospitalId", new { hospitalId });
var connectionString = builder.GetConnectionString(config.DataBaseType, config.DbSource, config.DbName, config.DbUser, config.DbPassword);
var connection = _factory.Create(config.DataBaseType, connectionString);
var hrp = _dbConnection.QueryFirst<ex_script>("select * from ex_script;");
var res = connection.Query<sub_subsidy>(hrp?.ExecScript, new { allotId }, commandTimeout: _commandTimeout);
var subsidy = _dbConnection.Query<sub_jobtitle>("select * from sub_jobtitle where AllotID=@allotId ;", new { allotId }).Select(t => new { t.JobTitle, t.BasicPerforFee }).Distinct();
//删除:在点击重新加载时删除记录重新插入
_dbConnection.Execute("delete from sub_subsidy where AllotID=@allotId;delete from sub_jobtitle where AllotID=@allotId;", new { allotId });
var jobtitle = res.Where(w=>!string.IsNullOrWhiteSpace(w.JobTitle)).Select(t => new
{
allotId,
t.JobTitle,
BasicPerforFee = subsidy.Where(w => w.JobTitle == t.JobTitle)?.Select(t => t.BasicPerforFee).FirstOrDefault()
}).Distinct();
var sql = $@"insert into sub_jobtitle(AllotID,JobTitle,BasicPerforFee) values (@allotId,@JobTitle,@BasicPerforFee);";
_dbConnection.Execute(sql, jobtitle);
sql = $@"insert into sub_subsidy (AllotID,Department,PersonnelNumber,PersonnelName,JobTitle,Attendance) values (@allotId,@Department,@PersonnelNumber,@PersonnelName,@JobTitle,@Attendance);";
var exmper = res.ToList().Select(t => new
{
AllotID = allotId,
t.Department,
t.PersonnelNumber,
t.PersonnelName,
t.JobTitle,
t.Attendance
});
var i = _dbConnection.Execute(sql, exmper);
}
catch (Exception e)
{
logger.LogError(e.Message);
throw e;
}
}
//职称标准保存
public bool SaveJobTitle(int allotId, List<sub_jobtitle> jobtitle)
{
try
{
var allot = GetAllot(allotId);
if (allot == null) throw new Exception("AllotId无效");
var result = jobtitle.Select(t => new { AllotID = allotId, t.BasicPerforFee, t.JobTitle });
var modify = _dbConnection.Execute($" update `sub_jobtitle` set BasicPerforFee =@BasicPerforFee WHERE AllotID=@allotId and JobTitle=@JobTitle; ", result);
_dbConnection.Execute("call proc_performance_subsidy(@allotId) ;", new { allotId });
return modify > 0;
}
catch (Exception e)
{
logger.LogError(e.Message);
throw e;
}
}
//个人职称补贴结果查询
public List<sub_subsidy> GetJobTitleSubsidy(int allotId)
{
try
{
var allot = GetAllot(allotId);
if (allot == null) throw new Exception("AllotId无效");
IEnumerable<sub_subsidy> _Subsidies = _dbConnection.Query<sub_subsidy>(@"select * from sub_subsidy where AllotID=@allotId ;", new { allotId });
return _Subsidies?.ToList();
}
catch (Exception e)
{
logger.LogError(e.Message);
throw e;
}
}
//个人职称补贴结果保存
public bool SaveJobTitleSubsidy(int allotId, List<sub_subsidy> subsidys)
{
try
{
var allot = GetAllot(allotId);
if (allot == null) throw new Exception("AllotId无效");
var result = subsidys.Select(t => new { t.RealAmount, AllotID = allotId, t.PersonnelNumber });
_dbConnection.Execute(@$"update sub_subsidy set GiveAmount = Attendance * BasicPerforFee, RealAmount = @RealAmount where AllotID=@allotId and PersonnelNumber=@PersonnelNumber;", result);
_dbConnection.Execute($@"call proc_performance_sync(@allotId);", new { allotId });
return true;
}
catch (Exception e)
{
logger.LogError(e.Message);
throw e;
}
}
public bool SaveSubsidy(int allotId, List<sub_subsidy> subsidys)
{
try
{
var allot = GetAllot(allotId);
if (allot == null) throw new Exception("AllotId无效");
var result = subsidys.Select(t => new { t.RealAmount, AllotID = allotId, t.PersonnelNumber });
_dbConnection.Execute(@$"update sub_subsidy set GiveAmount = Attendance * BasicPerforFee, RealAmount = @RealAmount where AllotID=@allotId and PersonnelNumber=@PersonnelNumber;", result);
return true;
}
catch (Exception e)
{
logger.LogError(e.Message);
throw e;
}
} }
} }
} }
...@@ -23,17 +23,17 @@ public IDbConnection CreateDefault() ...@@ -23,17 +23,17 @@ public IDbConnection CreateDefault()
return new MySqlConnection(_connectionString); return new MySqlConnection(_connectionString);
} }
public IDbConnection Create(DatabaseType type, string connectionString) public IDbConnection Create(int type, string connectionString)
{ {
try try
{ {
switch (type) switch (type)
{ {
case DatabaseType.MySQL: case (int)DatabaseType.MySQL:
return new MySqlConnection(connectionString); return new MySqlConnection(connectionString);
case DatabaseType.SqlServer: case (int)DatabaseType.SqlServer:
return new SqlConnection(connectionString); return new SqlConnection(connectionString);
case DatabaseType.Oracle: case (int)DatabaseType.Oracle:
return new OracleConnection(connectionString); return new OracleConnection(connectionString);
default: default:
throw new ArgumentException("DatabaseType类型不支持"); throw new ArgumentException("DatabaseType类型不支持");
......
...@@ -17,18 +17,18 @@ public ConnectionStringBuilder(IOptions<ConnectionStringTemplates> options) ...@@ -17,18 +17,18 @@ public ConnectionStringBuilder(IOptions<ConnectionStringTemplates> options)
_options = options; _options = options;
} }
public string GetConnectionString(DatabaseType type, string ip, string database, string uid, string pwd) public string GetConnectionString(int type, string ip, string database, string uid, string pwd)
{ {
switch (type) switch (type)
{ {
case DatabaseType.MySQL: case (int)DatabaseType.MySQL:
return string.Format(_options.Value.MySQLTemplates, ip, database, uid, pwd); return string.Format(_options.Value.MySQLTemplates, ip, database, uid, pwd);
case DatabaseType.SqlServer: case (int)DatabaseType.SqlServer:
return string.Format(_options.Value.MySQLTemplates, ip, database, uid, pwd); return string.Format(_options.Value.SqlServerTemplates, ip, database, uid, pwd);
case DatabaseType.Oracle: case (int)DatabaseType.Oracle:
return string.Format(_options.Value.MySQLTemplates, ip, database, uid, pwd); return string.Format(_options.Value.OracleTemplates, ip, database, uid, pwd);
default: default:
throw new ArgumentException("DatabaseType类型不支持"); throw new ArgumentException("DatabaseType类型不支持");
......
...@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 ...@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16 # Visual Studio Version 16
VisualStudioVersion = 16.0.31112.23 VisualStudioVersion = 16.0.31112.23
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Performance.Subsidy.Api", "Performance.Subsidy.Api\Performance.Subsidy.Api.csproj", "{B1560D0E-69D5-44DA-9C7E-AB548C709EE7}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Performance.Subsidy.Api", "Performance.Subsidy.Api\Performance.Subsidy.Api.csproj", "{B1560D0E-69D5-44DA-9C7E-AB548C709EE7}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Performance.Subsidy.Services", "Performance.Subsidy.Services\Performance.Subsidy.Services.csproj", "{75937D89-4F57-4D95-A03E-DD64D782C700}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Performance.Subsidy.Services", "Performance.Subsidy.Services\Performance.Subsidy.Services.csproj", "{75937D89-4F57-4D95-A03E-DD64D782C700}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
......
...@@ -369,5 +369,18 @@ public ApiResponse DeleteUser([CustomizeValidator(RuleSet = "Delete"), FromBody] ...@@ -369,5 +369,18 @@ public ApiResponse DeleteUser([CustomizeValidator(RuleSet = "Delete"), FromBody]
} }
#endregion #endregion
/// <summary>
/// 批量新增用户
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("BatchSaveUser")]
[HttpPost]
public ApiResponse BatchSaveUser()
{
return new ApiResponse(ResponseType.OK);
}
} }
} }
\ No newline at end of file
...@@ -258,7 +258,7 @@ public ConfigController(ConfigService configService, AllotService allotService) ...@@ -258,7 +258,7 @@ public ConfigController(ConfigService configService, AllotService allotService)
[HttpPost] [HttpPost]
public ApiResponse GetDrugtypeList([CustomizeValidator(RuleSet = "Select"), FromBody] DrugpropRequest request) public ApiResponse GetDrugtypeList([CustomizeValidator(RuleSet = "Select"), FromBody] DrugpropRequest request)
{ {
var list = _configService.GetDrugtypeList(request.HospitalId,request.AllotID); var list = _configService.GetDrugtypeList(request.HospitalId, request.AllotID);
return new ApiResponse(ResponseType.OK, "ok", list); return new ApiResponse(ResponseType.OK, "ok", list);
} }
...@@ -523,6 +523,79 @@ public ApiResponse DepttypeDelete([CustomizeValidator(RuleSet = "Delete"), FromB ...@@ -523,6 +523,79 @@ public ApiResponse DepttypeDelete([CustomizeValidator(RuleSet = "Delete"), FromB
//} //}
#endregion #endregion
#region accounting
/// <summary>
/// 获取cof_accounting列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("accountinglist/{allotId}/{type}")]
[HttpPost]
public ApiResponse GetAccountingList([FromBody] AccoungingRequest request)
{
if (request.AllotId == 0 || !new int[] { 1, 2, 3 }.Contains(request.Type))
return new ApiResponse(ResponseType.ParameterError);
var list = _configService.GetAccountingList(request) ?? new List<cof_accounting>();
switch (request.Type)
{
case 1:
default: //返回accounting列表
return new ApiResponse(ResponseType.OK, "ok", list);
case 2: //返回核算单元类型
return new ApiResponse(ResponseType.OK, "ok", list.Select(t => new TitleValue { Title = t.UnitType, Value = t.UnitType }).ToDistinct());
case 3: //返回核算单元
return new ApiResponse(ResponseType.OK, "ok", list.Select(t => new TitleValue { Title = t.AccountingUnit, Value = t.AccountingUnit }).ToDistinct());
}
}
/// <summary>
/// 新增cof_accounting
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("accountinginsert")]
[HttpPost]
public ApiResponse AccountingInsert([FromBody] cof_accounting request)
{
if (request.AllotId == 0 || string.IsNullOrEmpty(request.UnitType) || string.IsNullOrEmpty(request.AccountingUnit))
return new ApiResponse(ResponseType.ParameterError);
var drugprop = _configService.AccountingInsert(request);
return new ApiResponse(ResponseType.OK, drugprop);
}
/// <summary>
/// 修改cof_accounting
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("accountingupdate")]
[HttpPost]
public ApiResponse AccountingUpdate([FromBody] cof_accounting request)
{
if (request.AllotId == 0 || string.IsNullOrEmpty(request.UnitType) || string.IsNullOrEmpty(request.AccountingUnit))
return new ApiResponse(ResponseType.ParameterError);
var drugprop = _configService.AccountingUpdate(request);
return new ApiResponse(ResponseType.OK, drugprop);
}
/// <summary>
/// 删除cof_accounting
/// </summary>
/// <param name="accountingId"></param>
/// <returns></returns>
[Route("accountingdelete/{accountingId}")]
[HttpPost]
public ApiResponse AccountingDelete([FromRoute] int accountingId)
{
if (!_configService.AccountingDelete(accountingId))
return new ApiResponse(ResponseType.Fail);
return new ApiResponse(ResponseType.OK);
}
#endregion
/// <summary> /// <summary>
/// 获取工作量绩效列头 /// 获取工作量绩效列头
/// </summary> /// </summary>
...@@ -537,7 +610,7 @@ public ApiResponse WorkHeader([CustomizeValidator(RuleSet = "Select"), FromBody] ...@@ -537,7 +610,7 @@ public ApiResponse WorkHeader([CustomizeValidator(RuleSet = "Select"), FromBody]
} }
#region HRP人员科室 #region HRP人员科室
/// <summary> /// <summary>
/// 获取HRP人员科室 /// 获取HRP人员科室
/// </summary> /// </summary>
...@@ -569,7 +642,7 @@ public ApiResponse SaveHrpDept(int hospitalId, int allotId, [FromBody] SaveColle ...@@ -569,7 +642,7 @@ public ApiResponse SaveHrpDept(int hospitalId, int allotId, [FromBody] SaveColle
if (hospitalId <= 0) if (hospitalId <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "HospitalId无效"); return new ApiResponse(ResponseType.Fail, "参数错误", "HospitalId无效");
if (allotId <= 0) if (allotId <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "allotid无效"); return new ApiResponse(ResponseType.Fail, "参数错误", "allotid无效");
_configService.SaveDepttypeHands(hospitalId, allotId, request); _configService.SaveDepttypeHands(hospitalId, allotId, request);
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
...@@ -597,11 +670,11 @@ public ApiResponse GetSecondaryAlias() ...@@ -597,11 +670,11 @@ public ApiResponse GetSecondaryAlias()
[HttpPost] [HttpPost]
public ApiResponse SaveSecondaryAlias([FromBody] SaveCollectData request) public ApiResponse SaveSecondaryAlias([FromBody] SaveCollectData request)
{ {
_configService.SaveSecondaryAlias(request); _configService.SaveSecondaryAlias(request);
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
#endregion #endregion
} }
} }
\ No newline at end of file
using FluentScheduler;
using Microsoft.Extensions.DependencyInjection;
using Performance.Services;
using Performance.Services.ExtractExcelService;
namespace Performance.Api
{
public class ExtractGenerateJob : IJob
{
private readonly ExtractJobService extractJobService;
public ExtractGenerateJob()
{
this.extractJobService = ServiceLocator.Instance.GetService<ExtractJobService>();
}
public void Execute()
{
extractJobService.ExportFile();
}
}
}
...@@ -6,8 +6,9 @@ public class JobRegistry : Registry ...@@ -6,8 +6,9 @@ public class JobRegistry : Registry
{ {
public JobRegistry() public JobRegistry()
{ {
Schedule<ExtractDataJob>().ToRunNow().AndEvery(1).Days().At(23, 0); //Schedule<ExtractDataJob>().ToRunNow().AndEvery(1).Days().At(23, 0);
//Schedule<ExtractDataJob>().ToRunEvery(1).Days().At(23, 0); //Schedule<ExtractDataJob>().ToRunEvery(1).Days().At(23, 0);
Schedule<ExtractGenerateJob>().ToRunEvery(1).Days().At(1, 0);
} }
} }
} }
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
<CopyToOutputDirectory>Never</CopyToOutputDirectory> <CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content> </Content>
<Content Update="nlog.config"> <Content Update="nlog.config">
<CopyToOutputDirectory>Never</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<Content Update="wwwroot\Performance.Api.xml"> <Content Update="wwwroot\Performance.Api.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
......
...@@ -15,7 +15,19 @@ public class Program ...@@ -15,7 +15,19 @@ public class Program
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
CreateWebHostBuilder(args).Build().Run(); var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
try
{
CreateWebHostBuilder(args).Build().Run();
}
catch (Exception ex)
{
logger.Error(ex, "Stopped program because of exception");
}
finally
{
NLog.LogManager.Shutdown();
}
} }
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
...@@ -25,9 +37,14 @@ public static void Main(string[] args) ...@@ -25,9 +37,14 @@ public static void Main(string[] args)
var env = context.HostingEnvironment; var env = context.HostingEnvironment;
config.AddJsonFile("appsettings.json", true, true); config.AddJsonFile("appsettings.json", true, true);
config.AddJsonFile($"appsettings.{env.EnvironmentName}.json", true, true); config.AddJsonFile($"appsettings.{env.EnvironmentName}.json", true, true);
env.ConfigureNLog("nlog.config");
}) })
.UseUrls("http://*:5001") .UseUrls("http://*:5001")
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.SetMinimumLevel(LogLevel.Trace);
})
.UseNLog()
.UseStartup<Startup>(); .UseStartup<Startup>();
} }
} }
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
此文件由 Web 项目的发布/打包过程使用。可以通过编辑此 MSBuild 文件 https://go.microsoft.com/fwlink/?LinkID=208121.
自定义此过程的行为。为了解与此相关的更多内容,请访问 https://go.microsoft.com/fwlink/?LinkID=208121。
--> -->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod> <DeleteExistingFiles>True</DeleteExistingFiles>
<PublishProvider>FileSystem</PublishProvider> <ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration> <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform> <LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\Release\netcoreapp2.2\publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish /> <SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<TargetFramework>netcoreapp2.2</TargetFramework> <TargetFramework>netcoreapp2.2</TargetFramework>
<ProjectGuid>3ae00ff5-f0ba-4d72-a23b-770186309327</ProjectGuid> <ProjectGuid>3ae00ff5-f0ba-4d72-a23b-770186309327</ProjectGuid>
<SelfContained>false</SelfContained> <SelfContained>false</SelfContained>
<_IsPortable>true</_IsPortable>
<publishUrl>E:\release\jx.suvalue.com</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup> </PropertyGroup>
</Project> </Project>
\ No newline at end of file
...@@ -215,9 +215,8 @@ public void ConfigureServices(IServiceCollection services) ...@@ -215,9 +215,8 @@ public void ConfigureServices(IServiceCollection services)
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{ {
loggerFactory.AddNLog();
if (env.IsDevelopment()) if (env.IsDevelopment())
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
...@@ -248,8 +247,6 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF ...@@ -248,8 +247,6 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
app.UseCors("SignalrCore"); app.UseCors("SignalrCore");
app.UseSignalR(routes => routes.MapHub<AllotLogHub>("/performance/allotLogHub")); app.UseSignalR(routes => routes.MapHub<AllotLogHub>("/performance/allotLogHub"));
loggerFactory.CreateLogger<Startup>().LogDebug(env.EnvironmentName);
app.UseMvc(); app.UseMvc();
} }
} }
......
...@@ -137,6 +137,13 @@ ...@@ -137,6 +137,13 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.AccountController.BatchSaveUser">
<summary>
批量新增用户
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="T:Performance.Api.Controllers.AgainAllotController"> <member name="T:Performance.Api.Controllers.AgainAllotController">
<summary> <summary>
科室二次分配 科室二次分配
...@@ -600,6 +607,35 @@ ...@@ -600,6 +607,35 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ConfigController.GetAccountingList(System.Int32,System.Int32)">
<summary>
获取cof_accounting列表
</summary>
<param name="allotId"></param>
<param name="type">1 返回accounting列表 2 返回核算单元类型 3 返回核算单元</param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.AccountingInsert(Performance.EntityModels.cof_accounting)">
<summary>
新增cof_accounting
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.AccountingUpdate(Performance.EntityModels.cof_accounting)">
<summary>
修改cof_accounting
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.AccountingDelete(System.Int32)">
<summary>
删除cof_accounting
</summary>
<param name="accountingId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.WorkHeader(Performance.DtoModels.WorkItemRequest)"> <member name="M:Performance.Api.Controllers.ConfigController.WorkHeader(Performance.DtoModels.WorkItemRequest)">
<summary> <summary>
获取工作量绩效列头 获取工作量绩效列头
...@@ -1325,13 +1361,13 @@ ...@@ -1325,13 +1361,13 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.SecondAllotController.WorkTypeList(Performance.DtoModels.WorkloadRequest)"> <member name="M:Performance.Api.Controllers.SecondAllotController.WorkTypeList(Performance.DtoModels.WorkloadRequest,System.Int32)">
<summary> <summary>
二次绩效工作量类型列表 二次绩效工作量类型列表
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.SecondAllotController.SingleSave(Performance.EntityModels.ag_workload_type)"> <member name="M:Performance.Api.Controllers.SecondAllotController.SingleSave(Performance.EntityModels.ag_workload_type,System.Int32)">
<summary> <summary>
保存二次绩效工作量类型 保存二次绩效工作量类型
</summary> </summary>
......
...@@ -73,6 +73,9 @@ ...@@ -73,6 +73,9 @@
<member name="P:Performance.EntityModels.PerformanceDbContext.as_tempcolumns"> <member name="P:Performance.EntityModels.PerformanceDbContext.as_tempcolumns">
<summary> 考核列头 </summary> <summary> 考核列头 </summary>
</member> </member>
<member name="P:Performance.EntityModels.PerformanceDbContext.cof_accounting">
<summary> </summary>
</member>
<member name="P:Performance.EntityModels.PerformanceDbContext.cof_again"> <member name="P:Performance.EntityModels.PerformanceDbContext.cof_again">
<summary> </summary> <summary> </summary>
</member> </member>
...@@ -1623,6 +1626,31 @@ ...@@ -1623,6 +1626,31 @@
排序 排序
</summary> </summary>
</member> </member>
<member name="T:Performance.EntityModels.cof_accounting">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.cof_accounting.Id">
<summary>
</summary>
</member>
<member name="P:Performance.EntityModels.cof_accounting.AllotId">
<summary>
绩效Id
</summary>
</member>
<member name="P:Performance.EntityModels.cof_accounting.UnitType">
<summary>
核算单元类型
</summary>
</member>
<member name="P:Performance.EntityModels.cof_accounting.AccountingUnit">
<summary>
核算单元
</summary>
</member>
<member name="T:Performance.EntityModels.cof_again"> <member name="T:Performance.EntityModels.cof_again">
<summary> <summary>
......
namespace Performance.DtoModels
{
public class AccoungingRequest
{
/// <summary>
/// 绩效Id
/// </summary>
public int AllotId { get; set; }
/// <summary>
/// 1 返回accounting列表 2 返回核算单元类型 3 返回核算单元
/// </summary>
public int Type { get; set; }
/// <summary>
/// 核算单元类型、核算组别
/// </summary>
public string UnitType { get; set; }
}
}
...@@ -59,7 +59,9 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options) ...@@ -59,7 +59,9 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
public virtual DbSet<as_tempassess> as_tempassess { get; set; } public virtual DbSet<as_tempassess> as_tempassess { get; set; }
/// <summary> 考核列头 </summary> /// <summary> 考核列头 </summary>
public virtual DbSet<as_tempcolumns> as_tempcolumns { get; set; } public virtual DbSet<as_tempcolumns> as_tempcolumns { get; set; }
/// <summary> </summary> /// <summary> </summary>
public virtual DbSet<cof_accounting> cof_accounting { get; set; }
/// <summary> </summary>
public virtual DbSet<cof_again> cof_again { get; set; } public virtual DbSet<cof_again> cof_again { get; set; }
/// <summary> </summary> /// <summary> </summary>
public virtual DbSet<cof_alias> cof_alias { get; set; } public virtual DbSet<cof_alias> cof_alias { get; set; }
......
//-----------------------------------------------------------------------
// <copyright file=" cof_accounting.cs">
// * FileName: .cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Performance.EntityModels
{
/// <summary>
///
/// </summary>
[Table("cof_accounting")]
public class cof_accounting
{
/// <summary>
///
/// </summary>
[Key]
public int Id { get; set; }
/// <summary>
/// 绩效Id
/// </summary>
public int AllotId { get; set; }
/// <summary>
/// 核算单元类型
/// </summary>
public string UnitType { get; set; }
/// <summary>
/// 核算单元
/// </summary>
public string AccountingUnit { get; set; }
}
}
...@@ -56,6 +56,7 @@ public int DeleteAllotData(int allotId) ...@@ -56,6 +56,7 @@ public int DeleteAllotData(int allotId)
List<string> tableArray = new List<string> List<string> tableArray = new List<string>
{ {
"ag_secondallot", "ag_secondallot",
"cof_accounting",
"cof_again", "cof_again",
"cof_check", "cof_check",
"cof_cmi", "cof_cmi",
......
...@@ -183,13 +183,14 @@ public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, stri ...@@ -183,13 +183,14 @@ public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, stri
string unittype = unittypes.Any(t => !string.IsNullOrEmpty(t) && t.Contains("医生")) string unittype = unittypes.Any(t => !string.IsNullOrEmpty(t) && t.Contains("医生"))
? "医生组" ? "医生组"
: unittypes.Any(t => !string.IsNullOrEmpty(t) && t.Contains("护理")) ? "护理组" : "其他组"; : unittypes.Any(t => !string.IsNullOrEmpty(t) && t.Contains("护理")) ? "护理组" : "其他组";
string clear = @"SELECT DISTINCT t3.AccountingUnit as Department,ifnull(t1.DoctorName, '未知') DoctorName,t1.PersonnelNumber,t1.Category,t1.Fee FROM ex_result t1 string clear = @"SELECT DISTINCT t3.AccountingUnit as Department,ifnull(t1.DoctorName, '未知') DoctorName,t1.PersonnelNumber,t1.Category,SUM(t1.Fee) Fee FROM ex_result t1
JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = @hospitalid) t3 ON t1.Department = t3.HISDeptName JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = @hospitalid) t3 ON t1.Department = t3.HISDeptName
WHERE t1.allotid = @allotid WHERE t1.allotid = @allotid
AND t3.unittype in @unittypes AND t3.unittype in @unittypes
AND t3.accountingunit = @accountingunit AND t3.accountingunit = @accountingunit
AND t1.Source LIKE CONCAT('%',@unittype,'工作量%') AND t1.Source LIKE CONCAT('%',@unittype,'工作量%')
AND T1.IsDelete = 0 AND T1.IsDelete = 0
GROUP BY ifnull(t1.DoctorName, '未知'),t1.PersonnelNumber,t1.Category
ORDER BY t1.doctorname,t1.Category;"; ORDER BY t1.doctorname,t1.Category;";
return connection.Query<report_original_workload>(clear, new { allotid, accountingunit, unittypes, unittype, hospitalid }, commandTimeout: 60 * 60); return connection.Query<report_original_workload>(clear, new { allotid, accountingunit, unittypes, unittype, hospitalid }, commandTimeout: 60 * 60);
} }
...@@ -211,13 +212,14 @@ public IEnumerable<ex_result> QueryIncomeData(int allotid, string source, string ...@@ -211,13 +212,14 @@ public IEnumerable<ex_result> QueryIncomeData(int allotid, string source, string
if (connection.State != ConnectionState.Open) connection.Open(); if (connection.State != ConnectionState.Open) connection.Open();
try try
{ {
string clear = $@"SELECT DISTINCT t3.AccountingUnit as Department,ifnull(t1.DoctorName, '未知') DoctorName,t1.PersonnelNumber,t1.Category,t1.Fee FROM ex_result t1 string clear = $@"SELECT DISTINCT t3.AccountingUnit as Department,ifnull(t1.DoctorName, '未知') DoctorName,t1.PersonnelNumber,t1.Category,SUM(t1.Fee) Fee FROM ex_result t1
JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = @hospitalid) t3 ON t1.Department = t3.HISDeptName JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = @hospitalid) t3 ON t1.Department = t3.HISDeptName
WHERE t1.allotid = @allotid WHERE t1.allotid = @allotid
AND t3.unittype in @unittype AND t3.unittype in @unittype
AND t3.accountingunit = @accountingunit AND t3.accountingunit = @accountingunit
AND (t1.Source like '%{source}开单%' OR t1.Source like '%{source}就诊%') AND (t1.Source like '%{source}开单%' OR t1.Source like '%{source}就诊%')
AND T1.IsDelete = 0 AND T1.IsDelete = 0
GROUP BY ifnull(t1.DoctorName, '未知'),t1.PersonnelNumber,t1.Category
ORDER BY t1.doctorname,t1.Category;"; ORDER BY t1.doctorname,t1.Category;";
return connection.Query<ex_result>(clear, new { allotid, accountingunit, unittype, hospitalid }, commandTimeout: 60 * 60); return connection.Query<ex_result>(clear, new { allotid, accountingunit, unittype, hospitalid }, commandTimeout: 60 * 60);
} }
......
//-----------------------------------------------------------------------
// <copyright file=" cof_accounting.cs">
// * FileName: cof_accounting.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using Performance.EntityModels;
namespace Performance.Repository
{
/// <summary>
/// cof_accounting Repository
/// </summary>
public class PerforCofaccountingRepository : PerforRepository<cof_accounting>
{
public PerforCofaccountingRepository(PerformanceDbContext context) : base(context)
{
}
}
}
...@@ -17,23 +17,24 @@ namespace Performance.Services ...@@ -17,23 +17,24 @@ namespace Performance.Services
public class ConfigService : IAutoInjection public class ConfigService : IAutoInjection
{ {
#region #region
private PerforCofdirectorRepository _directorRepository; private readonly PerforCofdirectorRepository _directorRepository;
//private PerforCofdrugpropRepository _drugpropRepository; //private readonly PerforCofdrugpropRepository _drugpropRepository;
private PerforCofworkitemRepository _workitemRepository; private readonly PerforCofworkitemRepository _workitemRepository;
private PerforCofagainRepository _againRepository; private readonly PerforCofagainRepository _againRepository;
private PerforCofdrugtypeRepository _drugtypeRepository; private readonly PerforCofdrugtypeRepository _drugtypeRepository;
private PerforPerallotRepository perforPerAllotRepository; private readonly PerforPerallotRepository perforPerAllotRepository;
private PerforHospitalRepository perforHospitalRepository; private readonly PerforHospitalRepository perforHospitalRepository;
private PerforPersheetRepository perforPersheetRepository; private readonly PerforPersheetRepository perforPersheetRepository;
private PerforImheaderRepository perforImheaderRepository; private readonly PerforImheaderRepository perforImheaderRepository;
private PerforCofdepttypeRepository perforCofdepttypeRepository; private readonly PerforCofdepttypeRepository perforCofdepttypeRepository;
private PerforPerapramountRepository perapramountRepository; private readonly PerforPerapramountRepository perapramountRepository;
//private PerforCofcmiRepository perforCofcmiRepository; //private readonly PerforCofcmiRepository perforCofcmiRepository;
private PerforCofHrpDeptRepository perforCofHrpDeptRepository; private readonly PerforCofHrpDeptRepository perforCofHrpDeptRepository;
private PerforCofaliasRepository perforCofaliasRepository; private readonly PerforCofaliasRepository perforCofaliasRepository;
private PersonService personService; private readonly PerforCofaccountingRepository cofaccountingRepository;
private LogManageService logManageService; private readonly PersonService personService;
private ILogger<ConfigService> logger; private readonly LogManageService logManageService;
private readonly ILogger<ConfigService> logger;
public ConfigService(PerforCofdirectorRepository cofdirectorRepository, public ConfigService(PerforCofdirectorRepository cofdirectorRepository,
//PerforCofdrugpropRepository cofdrugpropRepository, //PerforCofdrugpropRepository cofdrugpropRepository,
...@@ -49,6 +50,7 @@ public class ConfigService : IAutoInjection ...@@ -49,6 +50,7 @@ public class ConfigService : IAutoInjection
//PerforCofcmiRepository perforCofcmiRepository, //PerforCofcmiRepository perforCofcmiRepository,
PerforCofHrpDeptRepository perforCofHrpDeptRepository, PerforCofHrpDeptRepository perforCofHrpDeptRepository,
PerforCofaliasRepository perforCofaliasRepository, PerforCofaliasRepository perforCofaliasRepository,
PerforCofaccountingRepository cofaccountingRepository,
PersonService personService, PersonService personService,
LogManageService logManageService, LogManageService logManageService,
ILogger<ConfigService> logger) ILogger<ConfigService> logger)
...@@ -67,6 +69,7 @@ public class ConfigService : IAutoInjection ...@@ -67,6 +69,7 @@ public class ConfigService : IAutoInjection
//this.perforCofcmiRepository = perforCofcmiRepository; //this.perforCofcmiRepository = perforCofcmiRepository;
this.perforCofHrpDeptRepository = perforCofHrpDeptRepository; this.perforCofHrpDeptRepository = perforCofHrpDeptRepository;
this.perforCofaliasRepository = perforCofaliasRepository; this.perforCofaliasRepository = perforCofaliasRepository;
this.cofaccountingRepository = cofaccountingRepository;
this.personService = personService; this.personService = personService;
this.logManageService = logManageService; this.logManageService = logManageService;
this.logger = logger; this.logger = logger;
...@@ -632,6 +635,73 @@ public bool AgainDelete(CofAgainRequest request) ...@@ -632,6 +635,73 @@ public bool AgainDelete(CofAgainRequest request)
#endregion #endregion
#region cof_accounting 核算单元及类别(4.1)配置
/// <summary>
/// 获取cof_accounting列表
/// </summary>
/// <returns></returns>
public List<cof_accounting> GetAccountingList(AccoungingRequest request)
{
var list = request.Type != 2 ? cofaccountingRepository.GetEntities(t => t.AllotId == request.AllotId)
: cofaccountingRepository.GetEntities(t => t.AllotId == request.AllotId && t.UnitType == request.UnitType);
return list;
}
/// <summary>
/// 添加数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public cof_accounting AccountingInsert(cof_accounting request)
{
var entity = new cof_accounting
{
AllotId = request.AllotId,
UnitType = request.UnitType,
AccountingUnit = request.AccountingUnit
};
if (!cofaccountingRepository.Add(entity))
throw new PerformanceException("保存失败");
return entity;
}
/// <summary>
/// 更新数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public cof_accounting AccountingUpdate(cof_accounting request)
{
var entity = cofaccountingRepository.GetEntity(t => t.Id == request.Id);
if (null == entity)
throw new PerformanceException($"ID不存在 :{request.Id}");
entity.AllotId = request.AllotId;
entity.UnitType = request.UnitType;
entity.AccountingUnit = request.AccountingUnit;
if (!cofaccountingRepository.Update(entity))
throw new PerformanceException("保存失败");
return entity;
}
/// <summary>
/// 删除数据
/// </summary>
/// <param name="accountingId"></param>
/// <returns></returns>
public bool AccountingDelete(int accountingId)
{
var entity = cofaccountingRepository.GetEntity(t => t.Id == accountingId);
if (null == entity)
throw new PerformanceException($"ID不存在 :{accountingId}");
return cofaccountingRepository.Remove(entity);
}
#endregion
#region Copy #region Copy
/// <summary> /// <summary>
...@@ -745,6 +815,16 @@ public void Copy(per_allot allot) ...@@ -745,6 +815,16 @@ public void Copy(per_allot allot)
{ AllotID = allot.ID, Type = t.Type, Department = t.Department, TypeName = t.TypeName, Value = t.TypeName == "满勤天数" ? days : t.Value }); { AllotID = allot.ID, Type = t.Type, Department = t.Department, TypeName = t.TypeName, Value = t.TypeName == "满勤天数" ? days : t.Value });
_againRepository.AddRange(newAgains.ToArray()); _againRepository.AddRange(newAgains.ToArray());
} }
logger.LogInformation($"accounting");
var accountings = cofaccountingRepository.GetEntities(t => t.AllotId == allot.ID);
if (accountings == null || accountings.Count == 0)
{
var prevData = cofaccountingRepository.GetEntities(t => t.AllotId == allotId);
var newData = prevData?.Select(t => new cof_accounting { AllotId = allot.ID, UnitType = t.UnitType, AccountingUnit = t.AccountingUnit });
if (newData != null && newData.Any())
cofaccountingRepository.AddRange(newData.ToArray());
}
} }
#endregion #endregion
......
...@@ -126,13 +126,13 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s ...@@ -126,13 +126,13 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
var row = sheet.GetRow(rowIndex); var row = sheet.GetRow(rowIndex);
if (row == null) continue; if (row == null) continue;
if (rowIndex > dataFirstRowNum) dataFirstRowNum = rowIndex + 1;
string department = row.GetOrCreate(dataFirstCellNum - 1).GetDecodeEscapes(); string department = row.GetOrCreate(dataFirstCellNum - 1).GetDecodeEscapes();
if (string.IsNullOrEmpty(department)) continue; if (string.IsNullOrEmpty(department)) continue;
if (rowIndex > dataFirstRowNum) dataFirstRowNum = rowIndex + 1;
var deptData = data.Where(t => t.Department == department); var deptData = data.Where(t => t.Department == department);
if (deptData == null || !deptData.Any()) continue; if (deptData == null || !deptData.Any(t => t.Value.HasValue && t.Value != 0)) continue;
#region 写入数据 #region 写入数据
...@@ -348,13 +348,13 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType ...@@ -348,13 +348,13 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
var row = sheet.GetRow(rowIndex); var row = sheet.GetRow(rowIndex);
if (row == null) continue; if (row == null) continue;
if (rowIndex > dataFirstRowNum) dataFirstRowNum = rowIndex + 1;
string department = row.GetOrCreate(dataFirstCellNum - 1).GetDecodeEscapes(); string department = row.GetOrCreate(dataFirstCellNum - 1).GetDecodeEscapes();
if (string.IsNullOrEmpty(department)) continue; if (string.IsNullOrEmpty(department)) continue;
if (rowIndex > dataFirstRowNum) dataFirstRowNum = rowIndex + 1;
var deptData = data.Where(t => t.Department == department); var deptData = data.Where(t => t.Department == department);
if (deptData == null || !deptData.Any()) continue; if (deptData == null || !deptData.Any(t => !string.IsNullOrEmpty(t.CellValue))) continue;
#region 写入数据 #region 写入数据
......
using Microsoft.Extensions.Logging; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Repository; using Performance.Repository;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
namespace Performance.Services.ExtractExcelService namespace Performance.Services.ExtractExcelService
...@@ -10,30 +14,36 @@ namespace Performance.Services.ExtractExcelService ...@@ -10,30 +14,36 @@ namespace Performance.Services.ExtractExcelService
public class ExtractJobService : IAutoInjection public class ExtractJobService : IAutoInjection
{ {
private readonly ILogger logger; private readonly ILogger logger;
private readonly IHostingEnvironment env;
private readonly AllotService allotService; private readonly AllotService allotService;
private readonly ConfigService configService; private readonly ConfigService configService;
private readonly DictionaryService dictionaryService; private readonly DictionaryService dictionaryService;
private readonly QueryService queryService; private readonly QueryService queryService;
private readonly ExtractService extractService;
private readonly PerforUserRepository userRepository; private readonly PerforUserRepository userRepository;
private readonly PerforHospitalRepository hospitalRepository; private readonly PerforHospitalRepository hospitalRepository;
private readonly PerforPerallotRepository perallotRepository; private readonly PerforPerallotRepository perallotRepository;
public ExtractJobService( public ExtractJobService(
ILogger<ExtractJobService> logger, ILogger<ExtractJobService> logger,
IHostingEnvironment env,
AllotService allotService, AllotService allotService,
ConfigService configService, ConfigService configService,
DictionaryService dictionaryService, DictionaryService dictionaryService,
QueryService queryService, QueryService queryService,
ExtractService extractService,
PerforUserRepository userRepository, PerforUserRepository userRepository,
PerforHospitalRepository hospitalRepository, PerforHospitalRepository hospitalRepository,
PerforPerallotRepository perallotRepository PerforPerallotRepository perallotRepository
) )
{ {
this.logger = logger; this.logger = logger;
this.env = env;
this.allotService = allotService; this.allotService = allotService;
this.configService = configService; this.configService = configService;
this.dictionaryService = dictionaryService; this.dictionaryService = dictionaryService;
this.queryService = queryService; this.queryService = queryService;
this.extractService = extractService;
this.userRepository = userRepository; this.userRepository = userRepository;
this.hospitalRepository = hospitalRepository; this.hospitalRepository = hospitalRepository;
this.perallotRepository = perallotRepository; this.perallotRepository = perallotRepository;
...@@ -41,6 +51,8 @@ PerforPerallotRepository perallotRepository ...@@ -41,6 +51,8 @@ PerforPerallotRepository perallotRepository
public void Execute() public void Execute()
{ {
logger.LogInformation($"Initial ExtractJobService start at {DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")};");
var hospitals = hospitalRepository.GetEntities(w => w.IsOpenTimedTasks == 1); var hospitals = hospitalRepository.GetEntities(w => w.IsOpenTimedTasks == 1);
if (hospitals == null || !hospitals.Any()) return; if (hospitals == null || !hospitals.Any()) return;
...@@ -77,6 +89,85 @@ public void Execute() ...@@ -77,6 +89,85 @@ public void Execute()
logger.LogError(ex.ToString()); logger.LogError(ex.ToString());
} }
} }
logger.LogInformation($"Initial ExtractJobService end at {DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")};");
}
public void ExportFile()
{
logger.LogInformation($"Initial Extract ImportFile Generate start at {DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")};");
var hospitals = hospitalRepository.GetEntities(w => w.IsOpenTimedTasks == 1);
if (hospitals == null || !hospitals.Any()) return;
var userId = userRepository.GetEntity(t => t.Login.ToLower() == "admin" && t.States == 1 && t.IsDelete == 1)?.ID ?? 1;
var date = DateTime.Now;
var allots = perallotRepository.GetEntities(t => hospitals.Select(w => w.ID).Contains(t.HospitalId));
foreach (var hospital in hospitals)
{
try
{
var allot = allots?.FirstOrDefault(t => t.HospitalId == hospital.ID && t.Year == date.Year && t.Month == date.Month);
if (allot == null)
{
allot = allotService.InsertAllot(new AllotRequest
{
HospitalId = hospital.ID,
Year = date.Year,
Month = date.Month
}, userId);
configService.Copy(allot);
}
if (allot == null || allot.ID == 0) continue;
var dict = new Dictionary<ExDataDict, object>();
var isSingle = hospital.IsSingleProject == 1;
var prevAllot = allots?.Where(t => t.HospitalId == hospital.ID && new int[] { 6, 8 }.Contains(t.States)).OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).First();
string filePath = prevAllot?.Path ?? "";
string extractFilePath = extractService.Main(allot.ID, allot.HospitalId, "", "User" + userId, filePath, isSingle);
if (string.IsNullOrEmpty(extractFilePath) || !FileHelper.IsExistFile(extractFilePath)) return;
ImportFile(allot, filePath);
allotService.Generate(allot);
}
catch (Exception ex)
{
logger.LogError(ex.ToString());
}
}
logger.LogInformation($"Initial Extract ImportFile Generate end at {DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")};");
}
private bool ImportFile(per_allot allot, string filePath)
{
var name = FileHelper.GetFileNameNoExtension(filePath) + DateTime.Now.ToString("yyyyMMddHHmmssfff");
var ext = FileHelper.GetExtension(filePath);
var dpath = Path.Combine(env.ContentRootPath, "Files", $"{allot.HospitalId}", $"{allot.Year}{allot.Month.ToString().PadLeft(2, '0')}");
FileHelper.CreateDirectory(dpath);
var path = Path.Combine(dpath, $"{name}{ext}");
using (var stream = new FileStream(filePath, FileMode.OpenOrCreate))
{
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
if (!FileHelper.CreateFile(path, bytes)) return false;
allot.Path = path;
allot.States = (int)AllotStates.FileUploaded;
allot.Remark = EnumHelper.GetDescription(AllotStates.FileUploaded);
allot.UploadDate = DateTime.Now;
allot.Generate = (int)AllotGenerate.Init;
if (!allotService.Update(allot)) return false;
}
configService.Clear(allot.ID);
return true;
} }
} }
} }
...@@ -141,14 +141,41 @@ private void WriteDataToFile(IWorkbook workbook, per_allot allot, Dictionary<ExD ...@@ -141,14 +141,41 @@ private void WriteDataToFile(IWorkbook workbook, per_allot allot, Dictionary<ExD
WriteDataFactory factory = new WriteDataFactory(); WriteDataFactory factory = new WriteDataFactory();
var types = new List<SheetType> { SheetType.OtherIncome, SheetType.Income, SheetType.Expend, SheetType.Workload, SheetType.OtherWorkload/*, SheetType.AccountBasic*/ }; var types = new List<SheetType> { SheetType.OtherIncome, SheetType.Income, SheetType.Expend, SheetType.Workload, SheetType.OtherWorkload/*, SheetType.AccountBasic*/ };
decimal ratio = 60m; decimal ratio = 60m;
string accountBasicSheetName = "";
for (int sheetIndex = 0; sheetIndex < workbook.NumberOfSheets; sheetIndex++)
{
var sheetName = workbook.GetSheetAt(sheetIndex).SheetName;
if (!sheetName.StartsWith("4.1"))
continue;
accountBasicSheetName = sheetName;
break;
}
var accountBasicSheet = workbook.GetSheet(accountBasicSheetName);
HandleSheet(workbook, allot, exdict, extractDto, groupName, isSingle, accountBasicSheet, ratio, types, factory, style, employeeDict, collectData);
for (int sheetIndex = 0; sheetIndex < workbook.NumberOfSheets; sheetIndex++) for (int sheetIndex = 0; sheetIndex < workbook.NumberOfSheets; sheetIndex++)
{ {
var sheet = workbook.GetSheetAt(sheetIndex); var sheet = workbook.GetSheetAt(sheetIndex);
HandleSheet(workbook, allot, exdict, extractDto, groupName, isSingle, sheet, ratio, types, factory, style, employeeDict, collectData);
}
}
private void HandleSheet(IWorkbook workbook, per_allot allot, Dictionary<ExDataDict, object> exdict, List<ExtractTransDto> extractDto, string groupName, bool isSingle,
ISheet sheet, decimal ratio, List<SheetType> types, WriteDataFactory factory, ExcelStyle style, List<per_employee> employeeDict, List<collect_data> collectData)
{
try
{
if (sheet == null) return;
string sheetName = sheet.SheetName.NoBlank(); string sheetName = sheet.SheetName.NoBlank();
ratio += 40m / workbook.NumberOfSheets; ratio += 40m / workbook.NumberOfSheets;
var sheetType = perSheetService.GetSheetType(sheet.SheetName); var sheetType = perSheetService.GetSheetType(sheet.SheetName);
if (sheetType == SheetType.Unidentifiable) continue; if (sheetType == SheetType.Unidentifiable) return;
logService.ReturnTheLog(allot.ID, groupName, 3, "", ratio > 99 ? 99 : ratio, 1, isSingle); logService.ReturnTheLog(allot.ID, groupName, 3, "", ratio > 99 ? 99 : ratio, 1, isSingle);
logService.ReturnTheLog(allot.ID, groupName, 2, "写入数据", $"sheet“{sheet.SheetName}”开始写入数据", 1, isSingle); logService.ReturnTheLog(allot.ID, groupName, 2, "写入数据", $"sheet“{sheet.SheetName}”开始写入数据", 1, isSingle);
...@@ -179,6 +206,10 @@ private void WriteDataToFile(IWorkbook workbook, per_allot allot, Dictionary<ExD ...@@ -179,6 +206,10 @@ private void WriteDataToFile(IWorkbook workbook, per_allot allot, Dictionary<ExD
logService.ReturnTheLog(allot.ID, groupName, 2, "写入数据", $"sheet“{sheet.SheetName}”已完成数据写入", 1, isSingle); logService.ReturnTheLog(allot.ID, groupName, 2, "写入数据", $"sheet“{sheet.SheetName}”已完成数据写入", 1, isSingle);
} }
catch (Exception ex)
{
logger.LogError("写入数据时发生异常:" + ex);
}
} }
private object GetDataBySheetType(int hospitalId, SheetType sheetType, List<ExtractTransDto> extractDto, List<per_employee> employeeDict) private object GetDataBySheetType(int hospitalId, SheetType sheetType, List<ExtractTransDto> extractDto, List<per_employee> employeeDict)
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using NPOI.SS.UserModel; using NPOI.SS.UserModel;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -24,7 +25,7 @@ public void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType sheetT ...@@ -24,7 +25,7 @@ public void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType sheetT
public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetType, ExcelStyle style, object data, Dictionary<ExDataDict, object> exdict = null) public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetType, ExcelStyle style, object data, Dictionary<ExDataDict, object> exdict = null)
{ {
if (data is List<per_dept_dic> departments && departments.Any()) if (data != null && data is List<per_dept_dic> departments && departments.Any())
{ {
int dataFirstRowNum = point.DataFirstRowNum.Value; int dataFirstRowNum = point.DataFirstRowNum.Value;
...@@ -36,8 +37,12 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetTyp ...@@ -36,8 +37,12 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetTyp
var tuples = GetAccountingUnitDataNonexistent(sheet, point, accountingUnits); var tuples = GetAccountingUnitDataNonexistent(sheet, point, accountingUnits);
accountingUnits = accountingUnits.Where(t => !t.AccountingUnit.Contains("非核算"))?.ToList();
if (accountingUnits == null || !accountingUnits.Any()) return; if (accountingUnits == null || !accountingUnits.Any()) return;
logger.LogInformation("4.1所有科室: " + JsonHelper.Serialize(accountingUnits));
WriteAccountingUnitDataNonexistent(sheet, point, style, accountingUnits, tuples); WriteAccountingUnitDataNonexistent(sheet, point, style, accountingUnits, tuples);
var accountBasic = new List<Account>(); var accountBasic = new List<Account>();
......
...@@ -143,6 +143,8 @@ private void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType sheet ...@@ -143,6 +143,8 @@ private void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType sheet
private static readonly Dictionary<string, Func<Account, string>> collectExtra = new Dictionary<string, Func<Account, string>> private static readonly Dictionary<string, Func<Account, string>> collectExtra = new Dictionary<string, Func<Account, string>>
{ {
{ "核算单元类型", (dto) => dto.UnitType }, { "核算单元类型", (dto) => dto.UnitType },
{ "核算组别", (dto) => dto.UnitType },
{ "核算单元分类", (dto) => dto.UnitType },
{ "核算单元", (dto) => dto.AccountingUnit }, { "核算单元", (dto) => dto.AccountingUnit },
}; };
} }
......
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