Commit b86bc909 by 李承祥

收入、工作量的核算单元,数据填充

parent 8aa2b332
......@@ -27,6 +27,10 @@ public IEnumerable<TEntity> DapperQuery(string sql, object param)
{
return context.Database.GetDbConnection().Query<TEntity>(sql, param);
}
public IEnumerable<TEntity> DapperQuery(string sql, object param, int? commandTimeout = null)
{
return context.Database.GetDbConnection().Query<TEntity>(sql, param, commandTimeout: commandTimeout);
}
public int Execute(string sql, object param)
{
......
......@@ -4,6 +4,7 @@
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using Performance.EntityModels;
namespace Performance.Repository
......@@ -16,5 +17,12 @@ public partial class PerforImdataRepository : PerforRepository<im_data>
public PerforImdataRepository(PerformanceDbContext context) : base(context)
{
}
public IEnumerable<im_data> GetAccountingUnit(List<int> sheetList, List<string> deptList)
{
string sql = "select distinct accountingUnit,department,unittype from im_data " +
"where sheetid in @sheetList and department in @deptList";
return DapperQuery(sql, new { sheetList, deptList }, 1000 * 60 * 5);
}
}
}
......@@ -32,6 +32,7 @@ public class ExtractService : IAutoInjection
private readonly PerforPersheetRepository perforPersheetRepository;
private readonly PerforImheaderRepository perforImheaderRepository;
private readonly PerforImemployeeRepository perforImemployeeRepository;
private readonly PerforImdataRepository perforImdataRepository;
private readonly PerforImaccountbasicRepository perforImaccountbasicRepository;
private readonly PerforExtractRepository perforExtractRepository;
private readonly PerforPerfirstRepository perforPerfirstRepository;
......@@ -46,6 +47,7 @@ public class ExtractService : IAutoInjection
PerforPersheetRepository perforPersheetRepository,
PerforImheaderRepository perforImheaderRepository,
PerforImemployeeRepository perforImemployeeRepository,
PerforImdataRepository perforImdataRepository,
PerforImaccountbasicRepository perforImaccountbasicRepository,
PerforExtractRepository perforExtractRepository,
PerforPerfirstRepository perforPerfirstRepository,
......@@ -60,6 +62,7 @@ public class ExtractService : IAutoInjection
this.perforPersheetRepository = perforPersheetRepository;
this.perforImheaderRepository = perforImheaderRepository;
this.perforImemployeeRepository = perforImemployeeRepository;
this.perforImdataRepository = perforImdataRepository;
this.perforImaccountbasicRepository = perforImaccountbasicRepository;
this.perforExtractRepository = perforExtractRepository;
this.perforPerfirstRepository = perforPerfirstRepository;
......@@ -262,7 +265,7 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
}
//临床科室医护绩效测算表
else if (SheetType.AccountBasic == sheet.SheetType /*&& sheet.PerData != null && sheet.PerData.Any()*/)
else if (SheetType.AccountBasic == sheet.SheetType && sheet.PerData != null && sheet.PerData.Any())
{
LogHelper.Information($"填充临床科室医护绩效测算表,", "提取绩效数据");
var dataList = sheet.PerData.ConvertAll(new Converter<IPerData, PerDataAccountBaisc>(t => (PerDataAccountBaisc)t));
......@@ -331,6 +334,12 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
var connection = ConnectionBuilder.Create(DatabaseType.SqlServer, hospitalConfig.DbSource, hospitalConfig.DbName, hospitalConfig.DbUser, hospitalConfig.DbPassword);
var dataList = perforExtractRepository.ExecuteScript(connection, script.ExecuteScript, null);
LogHelper.Information($"写入SQL脚本执行结果", "提取绩效数据");
//用于查询核算单元
var deptList = dataList.Where(t => t.ColumnName == "科室名称").Select(t => t.Value.ToString()).Distinct().ToList();
var sheetIdList = perforPersheetRepository.GetEntities(t => t.SheetType == (int)sheet.SheetType).Select(t => t.ID).ToList();
var imdata = perforImdataRepository.GetAccountingUnit(sheetIdList, deptList);
//创建数据行
foreach (var pointRow in dataList.Select(t => t.RowNumber).Distinct().OrderBy(t => t))
{
......@@ -344,6 +353,34 @@ private bool WriteExcel(string newpath, string originalPath, List<PerSheet> shee
{
importRow.CreateCell(headInfo.PointCell).SetCellValue(Verify(data.Value.ToString()));
}
if (data.ColumnName == "科室名称")
{
//补充核算单元
if (sheet.SheetType == SheetType.Income)
{
var doctor = imdata.FirstOrDefault(t => t.UnitType == 1 && t.Department == data.Value.ToString());
if (doctor != null)
importRow.CreateCell(0).SetCellValue(doctor.AccountingUnit);
var nurse = imdata.FirstOrDefault(t => t.UnitType == 2 && t.Department == data.Value.ToString());
if (nurse != null)
importRow.CreateCell(1).SetCellValue(nurse.AccountingUnit);
}
else if (sheet.SheetType == SheetType.Workload)
{
if (sheet.SheetName.Contains("医生"))
{
var doctor = imdata.FirstOrDefault(t => t.UnitType == 1 && t.Department == data.Value.ToString());
if (doctor != null)
importRow.CreateCell(0).SetCellValue(doctor.AccountingUnit);
}
else
{
var nurse = imdata.FirstOrDefault(t => t.UnitType == 2 && t.Department == data.Value.ToString());
if (nurse != null)
importRow.CreateCell(0).SetCellValue(nurse.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