Commit 0a860949 by ruyun.zhang@suvalue.com

Merge remote-tracking branch 'origin/feature/df' into dev

parents 9da16caa e73d4b6a
......@@ -160,8 +160,9 @@ public ApiResponse AddItem([FromBody]ItemListRequest request)
[HttpPost]
public ApiResponse Items([FromBody]ModItemRequest request)
{
logger.LogInformation($"请求地址 {url.HttpPost}/modextract/items");
logger.LogInformation($"绩效收入模板配置项列表 : 请求地址 {url.HttpPost}/modextract/items");
HttpHelper.HttpPost(url.HttpPost + "/modextract/items", JsonHelper.Serialize(request), true);
logger.LogInformation($"绩效收入模板配置项列表在{DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss完成请求")}");
var list = modExtractService.Items(request.ModuleId.Value);
return new ApiResponse(ResponseType.OK, list);
}
......
......@@ -233,7 +233,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
#endregion
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();
......
......@@ -136,6 +136,8 @@ public void ExtractData([FromForm] IFormCollection form, int allotId, int hospit
path = Path.Combine(dpath, FileHelper.GetFileName(file.FileName));
logger.LogInformation($"保存历史绩效文件保存路径:" + path);
if (!string.IsNullOrEmpty(path) && FileHelper.IsExistFile(path))
FileHelper.DeleteFile(path);
if (!string.IsNullOrEmpty(path) && FileHelper.IsExistFile(path))
FileHelper.DeleteFile(path);
......@@ -159,7 +161,11 @@ public void ExtractData([FromForm] IFormCollection form, int allotId, int hospit
if (!string.IsNullOrEmpty(filePath) && FileHelper.IsExistFile(filePath))
{
logger.LogInformation("请求路径:" + url.ImportFile + ",请求参数" + JsonHelper.Serialize(new { allotId, hospitalId }));
logger.LogInformation("请求路径:" + url.ImportFile + ",请求参数" + JsonHelper.Serialize(new
{
allotId,
hospitalId
}));
int i = 1;
while (i <= 5)
{
......
......@@ -262,7 +262,7 @@ public void Generate(per_allot allot, string mail)
if (!checkDataService.Check(excel, allot))
{
UpdateAllotStates(allot.ID, (int)AllotStates.CheckFail, EnumHelper.GetDescription(AllotStates.CheckFail));
SendEmail(allot, mail, 3, time);
//SendEmail(allot, mail, 3, time);
logManageService.WriteMsg("绩效数据校验失败", "详情可至“更多 -- 查看日志”查看", 3, allot.ID, "ReceiveMessage", true);
return;
}
......@@ -335,7 +335,7 @@ public void Generate(per_allot allot, string mail)
//发送邮件
logManageService.WriteMsg("正在发送邮件", "正在发送邮件", 1, allot.ID, "ReceiveMessage", true);
SendEmail(allot, mail, 1, time);
//SendEmail(allot, mail, 1, time);
//logdbug.Add(allot.ID, "绩效开始执行", "绩效生成成功");
logManageService.WriteMsg("绩效生成结束", "绩效生成成功", 5, allot.ID, "ReceiveMessage", true);
}
......@@ -344,7 +344,7 @@ public void Generate(per_allot allot, string mail)
logManageService.WriteMsg("绩效生成失败", "程序异常,请重新尝试。", 4, allot.ID, "ReceiveMessage");
logdbug.Add(allot.ID, "绩效开始执行", ex.ToString(), 4);
UpdateAllotStates(allot.ID, (int)AllotStates.GenerateFail, EnumHelper.GetDescription(AllotStates.GenerateFail));
SendEmail(allot, mail, 2, time);
//SendEmail(allot, mail, 2, time);
//throw ex;
}
}
......
......@@ -117,13 +117,14 @@ public string ExtractData(int allotId, string email, int hospitalId, string file
extractIds = extractIds.Distinct().ToList();
var extracts = perforModextractRepository.GetEntities(t => extractIds.Contains(t.Id));
return lastAllot == null ? TemplateExecute(email, lastAllot, hospital, configs, modules, items, specials, extracts) : AlllotExecute(email, lastAllot, hospital, configs, modules, items, specials, extracts, filePath);
return lastAllot == null ? TemplateExecute(email, hospital, configs, modules, items, specials, extracts)
: AlllotExecute(email, hospital, configs, modules, items, specials, extracts, lastAllot, filePath);
}
catch (Exception ex)
{
logManageService.WriteMsg("提取数据异常", $"数据写入出现异常", 4, Allot.ID, "ReceiveMessage");
logger.LogError($"提取绩效数据异常 数据写入出现异常{ex.ToString()}");
SendEmail(email, "", $"{hospital.HosName}HIS数据提取失败", $"{hospital.HosName}提取数据过程中出现异常情况,我们将尽快解决问题。给您带来的不便我们深感歉意!");
//SendEmail(email, "", $"{hospital.HosName}HIS数据提取失败", $"{hospital.HosName}提取数据过程中出现异常情况,我们将尽快解决问题。给您带来的不便我们深感歉意!");
throw ex;
}
finally
......@@ -148,7 +149,7 @@ public string ExtractData(int allotId, string email, int hospitalId, string file
/// <param name="specials"></param>
/// <param name="extracts"></param>
/// <returns></returns>
public string TemplateExecute(string email, per_allot lastAllot, sys_hospital hospital, List<sys_hospitalconfig> configs, List<mod_module> modules, List<mod_item> items, List<mod_special> specials, List<mod_extract> extracts)
public string TemplateExecute(string email, sys_hospital hospital, List<sys_hospitalconfig> configs, List<mod_module> modules, List<mod_item> items, List<mod_special> specials, List<mod_extract> extracts)
{
string originalPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Template", "东方医院绩效模板.xlsx");
var (tempPath, newPath) = CopyOriginalFile(hospital.ID, originalPath);
......@@ -159,8 +160,6 @@ public string TemplateExecute(string email, per_allot lastAllot, sys_hospital ho
style = CellStyle.CreateCellStyle(workbook, StyleType.数据);
List<AccountUnitEntity> unitList = new List<AccountUnitEntity>();
if (lastAllot != null)
unitList = perforImdataRepository.GetAccountUnit(lastAllot.ID).ToList();
for (int i = 0; i < workbook.NumberOfSheets; i++)
{
......@@ -194,7 +193,6 @@ public string TemplateExecute(string email, per_allot lastAllot, sys_hospital ho
}
logManageService.WriteMsg("提取绩效数据", $"{hospital.HosName}HIS数据提取成功,文件路径:{newPath}。", 5, Allot.ID, "ReceiveMessage");
logger.LogInformation($"提取绩效数据 {hospital.HosName}HIS数据提取成功,文件路径:{newPath}。");
ImportData(Allot, configs);
SendEmail(email, newPath, $"{hospital.HosName}HIS数据提取成功", $"{hospital.HosName}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}成功提取。");
return newPath;
......@@ -212,7 +210,7 @@ public string TemplateExecute(string email, per_allot lastAllot, sys_hospital ho
/// <param name="specials"></param>
/// <param name="extracts"></param>
/// <returns></returns>
public string AlllotExecute(string email, per_allot lastAllot, sys_hospital hospital, List<sys_hospitalconfig> configs, List<mod_module> modules, List<mod_item> items, List<mod_special> specials, List<mod_extract> extracts, string path)
public string AlllotExecute(string email, sys_hospital hospital, List<sys_hospitalconfig> configs, List<mod_module> modules, List<mod_item> items, List<mod_special> specials, List<mod_extract> extracts, per_allot lastAllot, string path)
{
if (string.IsNullOrEmpty(path)) throw new PerformanceException("历史绩效文件不存在!");
......@@ -231,29 +229,28 @@ public string AlllotExecute(string email, per_allot lastAllot, sys_hospital hosp
{
var sheet = workbook.GetSheetAt(i);
var sheetType = perSheetService.GetSheetType(sheet.SheetName);
if (sheetType == SheetType.Unidentifiable) continue;
var sheetRead = PerSheetDataFactory.GetDataRead(sheetType);
switch (sheetType)
{
case SheetType.OtherIncome:
ClearData(sheet, 5);
ClearData(sheet, 5, 4);
WriteOtherIncome(sheet, sheetRead, unitList, configs, modules, items, extracts, false);
break;
case SheetType.Income:
ClearData(sheet, 5);
ClearData(sheet, 5, 4, true);
WriteIncome(sheet, sheetRead, unitList, configs, modules, items, extracts, false);
break;
case SheetType.Expend:
ClearData(sheet, 5);
ClearData(sheet, 5, 4);
WriteExpend(sheet, sheetRead, unitList, configs, modules, items, extracts, false);
break;
case SheetType.Workload:
ClearData(sheet, 3);
ClearData(sheet, 3, 2);
WriteWorkload(sheet, sheetRead, unitList, configs, modules, items, extracts, false);
break;
case SheetType.SpecialUnit:
ClearData(sheet, 2);
ClearData(sheet, 2, 0);
WriteSpecialUnit(sheet, sheetRead, configs, specials, extracts, false, lastAllot);
break;
}
......@@ -264,7 +261,6 @@ public string AlllotExecute(string email, per_allot lastAllot, sys_hospital hosp
}
logManageService.WriteMsg("提取绩效数据", $"{hospital.HosName}HIS数据提取成功,文件路径:{newPath}。", 5, Allot.ID, "ReceiveMessage");
logger.LogInformation($"提取绩效数据 {hospital.HosName}HIS数据提取成功,文件路径:{newPath}。");
ImportData(Allot, configs);
SendEmail(email, newPath, $"{hospital.HosName}HIS数据提取成功", $"{hospital.HosName}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}成功提取。");
return newPath;
......@@ -315,7 +311,7 @@ private static void CreateNotExistSheet(List<mod_module> modulesList, IWorkbook
}
}
private void ClearData(ISheet sheet, int beginRowNum)
private void ClearData(ISheet sheet, int beginRowNum, int beginCellNum, bool isIncome = false)
{
if (sheet == null)
return;
......@@ -325,10 +321,11 @@ private void ClearData(ISheet sheet, int beginRowNum)
var row = sheet.GetRow(i);
if (row != null)
{
for (int j = 0; j < row.LastCellNum + 1; j++)
//跳过核算单元和科室
for (int j = beginCellNum; j < row.LastCellNum; j++)
{
var cell = row.GetCell(j);
if (cell != null && cell.CellType != CellType.Formula)
if (cell != null && (cell.CellType != CellType.Formula || isIncome))
{
cell.RemoveCellComment();
row.RemoveCell(cell);
......@@ -363,16 +360,17 @@ private ICell GetOrCreate(IRow row, int index)
#region SheetData
private void WriteOtherIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<sys_hospitalconfig> configs, List<mod_module> modules, List<mod_item> items, List<mod_extract> extracts, bool IsWriteHead = true)
private void WriteOtherIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<sys_hospitalconfig> configs, List<mod_module> modules, List<mod_item> items, List<mod_extract> extracts, bool isNewTemp = true)
{
logger.LogInformation($"{sheet.SheetName}开始提取.");
var module = modules.FirstOrDefault(t => t.SheetType == (int)SheetType.OtherIncome);
if (module == null) return;
var itemList = items.Where(t => t.ModuleId == module.Id).ToList();
logger.LogInformation($"item有{itemList?.Count ?? 0}个.");
if (itemList == null || !itemList.Any()) return;
if (IsWriteHead)
WriteHeaderAndFactor(sheet, sheetRead, itemList);
WriteHeaderAndFactor(sheet, sheetRead, itemList, isNewTemp);
//查询数据
var extractIdList = itemList.Select(t => t.ExtractId).Distinct().ToList();
......@@ -397,19 +395,21 @@ private void WriteOtherIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<Ac
}
}
WriteSheetData(sheet, sheetRead, unitList, allExtract);
WriteSheetData(sheet, sheetRead, unitList, allExtract, itemList.Select(t => t.ItemName), isNewTemp);
logger.LogInformation($"{sheet.SheetName}提取结束.");
}
private void WriteIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<sys_hospitalconfig> configs, List<mod_module> modules, List<mod_item> items, List<mod_extract> extracts, bool IsWriteHead = true)
private void WriteIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<sys_hospitalconfig> configs, List<mod_module> modules, List<mod_item> items, List<mod_extract> extracts, bool isNewTemp = true)
{
var module = modules.FirstOrDefault(t => t.ModuleName == sheet.SheetName);
logger.LogInformation($"{sheet.SheetName}开始提取.");
var module = modules.FirstOrDefault(t => t.ModuleName.Replace(" ", "") == sheet.SheetName.Replace(" ", ""));
if (module == null) return;
var itemList = items.Where(t => t.ModuleId == module.Id).ToList();
logger.LogInformation($"item有{itemList?.Count ?? 0}个.");
if (itemList == null || !itemList.Any()) return;
if (IsWriteHead)
WriteHeaderAndFactor(sheet, sheetRead, itemList);
WriteHeaderAndFactor(sheet, sheetRead, itemList, isNewTemp);
//查询数据
var extractList = extracts.Where(t => module.ExtractId == t.Id).ToList();
......@@ -428,19 +428,21 @@ private void WriteIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<Account
allExtract.AddRange(result);
}
WriteSheetData(sheet, sheetRead, unitList, allExtract);
WriteSheetData(sheet, sheetRead, unitList, allExtract, itemList.Select(t => t.ItemName), isNewTemp, true);
logger.LogInformation($"{sheet.SheetName}提取结束.");
}
private void WriteExpend(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<sys_hospitalconfig> configs, List<mod_module> modules, List<mod_item> items, List<mod_extract> extracts, bool IsWriteHead = true)
private void WriteExpend(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<sys_hospitalconfig> configs, List<mod_module> modules, List<mod_item> items, List<mod_extract> extracts, bool isNewTemp = true)
{
logger.LogInformation($"{sheet.SheetName}开始提取.");
var module = modules.FirstOrDefault(t => t.SheetType == (int)SheetType.Expend);
if (module == null) return;
var itemList = items.Where(t => t.ModuleId == module.Id).ToList();
logger.LogInformation($"item有{itemList?.Count ?? 0}个.");
if (itemList == null || !itemList.Any()) return;
if (IsWriteHead)
WriteHeaderAndFactor(sheet, sheetRead, itemList);
WriteHeaderAndFactor(sheet, sheetRead, itemList, isNewTemp);
//查询数据
var extractIdList = itemList.Select(t => t.ExtractId).Distinct().ToList();
......@@ -465,38 +467,21 @@ private void WriteExpend(ISheet sheet, IPerSheetDataRead sheetRead, List<Account
}
}
WriteSheetData(sheet, sheetRead, unitList, allExtract);
WriteSheetData(sheet, sheetRead, unitList, allExtract, itemList.Select(t => t.ItemName), isNewTemp);
logger.LogInformation($"{sheet.SheetName}提取结束.");
}
private void WriteWorkload(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<sys_hospitalconfig> configs, List<mod_module> modules, List<mod_item> items, List<mod_extract> extracts, bool IsWriteHead = true)
private void WriteWorkload(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<sys_hospitalconfig> configs, List<mod_module> modules, List<mod_item> items, List<mod_extract> extracts, bool isNewTemp = true)
{
var module = modules.FirstOrDefault(t => t.ModuleName == sheet.SheetName);
logger.LogInformation($"{sheet.SheetName}开始提取.");
var module = modules.FirstOrDefault(t => t.ModuleName.Replace(" ", "") == sheet.SheetName.Replace(" ", ""));
if (module == null) return;
var itemList = items.Where(t => t.ModuleId == module.Id).ToList();
logger.LogInformation($"item有{itemList?.Count ?? 0}个.");
if (itemList == null || !itemList.Any()) return;
var head = GetOrCreate(sheet, sheetRead.Point.HeaderFirstRowNum.Value + 0);
var factor = GetOrCreate(sheet, sheetRead.Point.HeaderFirstRowNum.Value + 1);
if (IsWriteHead)
{
logManageService.WriteMsg("提取绩效数据", $"写入列头信息 -- {module.ModuleName}", 1, Allot.ID, "ReceiveMessage");
logger.LogInformation($"提取绩效数据 写入列头信息 -- {module.ModuleName}");
//写入列头信息
int cellStartIndex = sheetRead.Point.HeaderFirstCellNum.Value + 2;
foreach (var item in itemList)
{
var headcell = GetOrCreate(head, cellStartIndex);
headcell.SetCellValue(item.ItemName);
headcell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.列头);
var doctorcell = GetOrCreate(factor, cellStartIndex);
doctorcell.SetCellValue(item.FactorValue1 != null ? (double)item.FactorValue1 : 0);
doctorcell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.列头, CellFormat.数字2);
cellStartIndex++;
}
}
WriteWorkHeader(sheet, sheetRead, itemList, isNewTemp);
//查询数据
var extractIdList = itemList.Select(t => t.ExtractId).Distinct().ToList();
......@@ -531,36 +516,8 @@ private void WriteWorkload(ISheet sheet, IPerSheetDataRead sheetRead, List<Accou
logManageService.WriteMsg("提取绩效数据", $"填充数据 -- {module.ModuleName}", 1, Allot.ID, "ReceiveMessage");
logger.LogInformation($"提取绩效数据 填充数据 -- {module.ModuleName}");
//写入数据
var rowIndex = sheetRead.Point.HeaderFirstRowNum.Value + 2;
foreach (var department in allExtract.Select(t => t.Department).Distinct())
{
var row = sheet.CreateRow(rowIndex);
for (int i = head.FirstCellNum; i < head.LastCellNum; i++)
{
var headName = head.GetCell(i).StringCellValue;
var newCell = row.CreateCell(i);
if (headName == "核算单元")
{
var dept = unitList.FirstOrDefault(t => t.SheetName == sheet.SheetName && t.Department == department)?.AccountingUnit;
newCell.SetCellValue(dept ?? "");
newCell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.默认);
}
else if (headName == "科室名称")
{
newCell.SetCellValue(department ?? "");
newCell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.默认);
}
else
{
var extract = allExtract.FirstOrDefault(t => t.Department == department && t.Category == headName);
var value = extract?.Value == 0 ? null : extract?.Value;
OutToExcelCell(newCell, value);
if (specialHead != null && specialHead.Contains(headName))
newCell.CellStyle = style;
}
}
rowIndex++;
}
WriteWorkData(sheet, sheetRead, unitList, allExtract, specialHead, isNewTemp);
logger.LogInformation($"{sheet.SheetName}提取结束.");
}
#region WriteAccountBasic
......@@ -616,6 +573,7 @@ private void WriteWorkload(ISheet sheet, IPerSheetDataRead sheetRead, List<Accou
private void WriteSpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<sys_hospitalconfig> configs, List<mod_special> specials, List<mod_extract> extracts, bool IsWriteHead = true, per_allot lastAllot = null)
{
logger.LogInformation($"{sheet.SheetName}开始提取.");
var dictionary = new Dictionary<string, Func<mod_special, List<im_specialunit>, object>>
{
{ "科室", (special,lastallot) => special.Department },
......@@ -626,6 +584,7 @@ private void WriteSpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<sy
};
var speaialList = specials?.OrderBy(t => t.Department).ToList();
logger.LogInformation($"item有{speaialList?.Count ?? 0}个.");
if (speaialList == null || !speaialList.Any()) return;
List<im_specialunit> allotDataList = new List<im_specialunit>();
......@@ -727,9 +686,18 @@ private void WriteSpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<sy
}
mergedBegin = mergedEnd + 1;
}
logger.LogInformation($"{sheet.SheetName}提取结束.");
}
private void WriteHeaderAndFactor(ISheet sheet, IPerSheetDataRead sheetRead, List<mod_item> items)
#region 写入数据
/// <summary>
/// 写入列头
/// </summary>
/// <param name="sheet"></param>
/// <param name="sheetRead"></param>
/// <param name="items">列头数据(列名、系数)</param>
/// <param name="isNewTemp">是否为空白模板</param>
private void WriteHeaderAndFactor(ISheet sheet, IPerSheetDataRead sheetRead, List<mod_item> items, bool isNewTemp)
{
var nurseFactor = sheet.GetRow(sheetRead.Point.AccountingUnit.First(t => t.UnitType == "护理组").FactorRow.Value);
var doctorFactor = sheet.GetRow(sheetRead.Point.AccountingUnit.First(t => t.UnitType == "医生组").FactorRow.Value);
......@@ -738,39 +706,114 @@ private void WriteHeaderAndFactor(ISheet sheet, IPerSheetDataRead sheetRead, Lis
logManageService.WriteMsg("提取绩效数据", $"写入列头信息 -- {sheet.SheetName}", 1, Allot.ID, "ReceiveMessage");
logger.LogInformation($"提取绩效数据 提取绩效数据 写入列头信息 -- {sheet.SheetName}");
var cellItems = items;
if (!isNewTemp)
{
#region 过滤历史模板中已有的列头
//写入列头信息
int cellStartIndex = sheetRead.Point.HeaderFirstCellNum.Value + 4;
foreach (var item in items)
for (int i = cellStartIndex; i < head.LastCellNum; i++)
{
var headcell = GetOrCreate(head, cellStartIndex);
var cellvalue = head.GetCell(i)?.ToString();
if (string.IsNullOrEmpty(cellvalue)) continue;
cellItems.RemoveAll(t => t.ItemName == cellvalue);
}
#endregion
}
if (cellItems == null || !cellItems.Any()) return;
#region 新增模板中不存在的列头
var lastcellIndex = head.LastCellNum;
foreach (var item in cellItems)
{
var headcell = GetOrCreate(head, lastcellIndex);
headcell.SetCellValue(item.ItemName);
headcell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.列头);
var doctorcell = GetOrCreate(doctorFactor, cellStartIndex);
var doctorcell = GetOrCreate(doctorFactor, lastcellIndex);
doctorcell.SetCellValue(item.FactorValue1 != null ? (double)item.FactorValue1 : 0);
doctorcell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.系数, CellFormat.百分比);
var nursecell = GetOrCreate(nurseFactor, cellStartIndex);
var nursecell = GetOrCreate(nurseFactor, lastcellIndex);
nursecell.SetCellValue(item.FactorValue2 != null ? (double)item.FactorValue2 : 0);
nursecell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.系数, CellFormat.百分比);
var techniciancell = GetOrCreate(technicianFactor, cellStartIndex);
var techniciancell = GetOrCreate(technicianFactor, lastcellIndex);
techniciancell.SetCellValue(item.FactorValue3 != null ? (double)item.FactorValue3 : 0);
techniciancell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.系数, CellFormat.百分比);
cellStartIndex++;
lastcellIndex++;
}
#endregion
}
private void WriteSheetData(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<ExtractDto> allExtract)
/// <summary>
/// 写入数据
/// </summary>
/// <param name="sheet"></param>
/// <param name="sheetRead"></param>
/// <param name="unitList">核算单元</param>
/// <param name="allExtract">抽取的数据(科室、列头、数据)</param>
/// <param name="header">设定抽取的列头</param>
/// <param name="isNewTemp">是否为空白模板</param>
/// <param name="isIncom">是否是开单、执行收入</param>
private void WriteSheetData(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<ExtractDto> allExtract, IEnumerable<string> header, bool isNewTemp, bool isIncom = false)
{
logManageService.WriteMsg("提取绩效数据", $"填充数据 -- {sheet.SheetName}", 1, Allot.ID, "ReceiveMessage");
logger.LogInformation($"提取绩效数据 填充数据 -- {sheet.SheetName}");
//写入数据
var head = GetOrCreate(sheet, sheetRead.Point.HeaderFirstRowNum.Value);
var rowIndex = sheetRead.Point.HeaderFirstRowNum.Value + 1;
foreach (var department in allExtract.Select(t => t.Department).Distinct())
if (!isNewTemp)
{
var row = sheet.CreateRow(rowIndex);
#region 给历史模板已有科室补充数据
for (int i = rowIndex; i < sheet.LastRowNum + 1; i++)
{
var row = sheet.GetRow(i);
if (row != null)
{
var department = row.GetCell(3)?.ToString();
if (string.IsNullOrEmpty(department)) continue;
var deptData = allExtract.Where(t => t.Department == department);
if (deptData == null || !deptData.Any()) continue;
for (int j = rowIndex; j < head.LastCellNum; j++)
{
var headName = head.GetCell(j).StringCellValue;
var newCell = GetOrCreate(row, j);
if (newCell == null) continue;
var value = deptData.FirstOrDefault(t => t.Category == headName)?.Value;
if (isIncom)
{
value = value == 0 ? null : value;
OutToExcelCell(newCell, value);
newCell.CellStyle = style;
}
else if (newCell.CellType != CellType.Formula)
{
value = value == 0 ? null : value;
OutToExcelCell(newCell, value);
if (header != null && header.Contains(headName))
newCell.CellStyle = style;
}
}
allExtract.RemoveAll(t => t.Department == department);
}
}
#endregion
}
if (allExtract == null || !allExtract.Any()) return;
#region 补充新的科室及数据
var lastrowIndex = sheet.LastRowNum + 1;
foreach (var department in allExtract.Select(t => t.Department).Where(t => !string.IsNullOrEmpty(t)).Distinct())
{
var row = sheet.CreateRow(lastrowIndex);
for (int i = head.FirstCellNum; i < head.LastCellNum; i++)
{
var headName = head.GetCell(i).StringCellValue;
......@@ -801,15 +844,157 @@ private void WriteSheetData(ISheet sheet, IPerSheetDataRead sheetRead, List<Acco
else
{
var value = allExtract.FirstOrDefault(t => t.Department == department && t.Category == headName)?.Value;
if (isIncom)
{
value = value == 0 ? null : value;
OutToExcelCell(newCell, value);
newCell.CellStyle = style;
}
else if (header != null && header.Contains(headName))
{
value = value == 0 ? null : value;
OutToExcelCell(newCell, value);
newCell.CellStyle = style;
}
}
rowIndex++;
}
lastrowIndex++;
}
#endregion
}
/// <summary>
/// 写入工作量列头
/// </summary>
/// <param name="sheet"></param>
/// <param name="sheetRead"></param>
/// <param name="items"></param>
/// <param name="isNewTemp"></param>
private void WriteWorkHeader(ISheet sheet, IPerSheetDataRead sheetRead, List<mod_item> items, bool isNewTemp)
{
var head = GetOrCreate(sheet, sheetRead.Point.HeaderFirstRowNum.Value + 0);
var factor = GetOrCreate(sheet, sheetRead.Point.HeaderFirstRowNum.Value + 1);
var cellItems = items;
if (!isNewTemp)
{
#region 过滤历史模板中已有的列头
//写入列头信息
int cellStartIndex = sheetRead.Point.HeaderFirstCellNum.Value + 4;
for (int i = cellStartIndex; i < head.LastCellNum; i++)
{
var cellvalue = head.GetCell(i)?.ToString();
if (string.IsNullOrEmpty(cellvalue)) continue;
cellItems.RemoveAll(t => t.ItemName == cellvalue);
}
#endregion
}
if (cellItems == null || !cellItems.Any()) return;
#region 新增模板中不存在的列头
var lastcellIndex = head.LastCellNum;
foreach (var item in cellItems)
{
var headcell = GetOrCreate(head, lastcellIndex);
headcell.SetCellValue(item.ItemName);
headcell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.列头);
var doctorcell = GetOrCreate(factor, lastcellIndex);
doctorcell.SetCellValue(item.FactorValue1 != null ? (double)item.FactorValue1 : 0);
doctorcell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.列头, CellFormat.数字2);
lastcellIndex++;
}
#endregion
}
/// <summary>
/// 写入工作量数据
/// </summary>
/// <param name="sheet"></param>
/// <param name="sheetRead"></param>
/// <param name="unitList"></param>
/// <param name="allExtract"></param>
/// <param name="header"></param>
/// <param name="isNewTemp"></param>
private void WriteWorkData(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<ExtractDto> allExtract, IEnumerable<string> header, bool isNewTemp)
{
var head = GetOrCreate(sheet, sheetRead.Point.HeaderFirstRowNum.Value + 0);
var rowIndex = sheetRead.Point.HeaderFirstRowNum.Value + 2;
if (!isNewTemp)
{
#region 给历史模板已有科室补充数据
for (int i = rowIndex; i < sheet.LastRowNum + 1; i++)
{
var row = sheet.GetRow(i);
if (row != null)
{
var department = row.GetCell(1)?.ToString();
if (string.IsNullOrEmpty(department)) continue;
var deptData = allExtract.Where(t => t.Department == department);
if (deptData == null || !deptData.Any()) continue;
for (int j = rowIndex; j < head.LastCellNum; j++)
{
var headName = head.GetCell(j).StringCellValue;
var newCell = GetOrCreate(row, j);
if (newCell == null) continue;
if (newCell.CellType != CellType.Formula)
{
var extract = deptData.FirstOrDefault(t => t.Category == headName);
var value = extract?.Value == 0 ? null : extract?.Value;
OutToExcelCell(newCell, value);
if (header != null && header.Contains(headName))
newCell.CellStyle = style;
}
}
allExtract.RemoveAll(t => t.Department == department);
}
}
#endregion
}
if (allExtract == null || !allExtract.Any()) return;
#region 补充新的科室及数据
var lastrowIndex = sheet.LastRowNum + 1;
foreach (var department in allExtract.Select(t => t.Department).Where(t => !string.IsNullOrEmpty(t)).Distinct())
{
var row = sheet.CreateRow(lastrowIndex);
for (int i = head.FirstCellNum; i < head.LastCellNum; i++)
{
var headName = head.GetCell(i).StringCellValue;
var newCell = row.CreateCell(i);
if (headName == "核算单元")
{
var dept = unitList.FirstOrDefault(t => t.SheetName == sheet.SheetName
&& t.Department == department)?.AccountingUnit;
newCell.SetCellValue(dept ?? "");
newCell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.默认);
}
else if (headName == "科室名称")
{
newCell.SetCellValue(department ?? "");
newCell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.默认);
}
else
{
var extract = allExtract.FirstOrDefault(t => t.Department == department && t.Category == headName);
var value = extract?.Value == 0 ? null : extract?.Value;
OutToExcelCell(newCell, value);
if (header != null && header.Contains(headName))
newCell.CellStyle = style;
}
}
lastrowIndex++;
}
#endregion
}
#endregion
#endregion
#region QueryData
......@@ -827,8 +1012,9 @@ private List<ExtractDto> QueryDatabase(sys_hospitalconfig config, mod_extract ex
executeScript = Regex.Replace(executeScript, item.Key, item.Value, RegexOptions.IgnoreCase);
}
//logManageService.WriteMsg("提取绩效数据", $"SQL脚本:{executeScript}", 1, AllotId, "ReceiveMessage");
logger.LogInformation($"提取绩效数据 SQL脚本{executeScript}");
logger.LogInformation($"提取绩效数据 {category ?? ""}SQL脚本{executeScript}");
var result = connection.Query<ExtractDto>(executeScript, commandTimeout: 20000);
logger.LogInformation($"提取绩效数据 {category ?? ""} 执行脚本获取数据{result?.Count() ?? 0}条记录");
if (result != null && result.Count() > 0)
{
if (extract.ExecuteType == 2)
......
......@@ -9,6 +9,12 @@
namespace Performance.Services
{
public class HubGroupInfo
{
public DateTime AddTime { get; set; }
public string ConnectionId { get; set; }
}
public class AllotLogHub : Hub
{
private readonly ILogger<AllotLogHub> logger;
......
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
using Performance.Repository;
using System;
using System.Collections.Generic;
......@@ -9,11 +10,15 @@ namespace Performance.Services
{
public class LogManageService : IAutoInjection
{
private readonly ILogger<LogManageService> logger;
private readonly IHubContext<AllotLogHub> hubContext;
private PerforLogdbugRepository logdbug;
public LogManageService(IHubContext<AllotLogHub> hubContext,
public LogManageService(
ILogger<LogManageService> logger,
IHubContext<AllotLogHub> hubContext,
PerforLogdbugRepository logdbug)
{
this.logger = logger;
this.hubContext = hubContext;
this.logdbug = logdbug;
}
......@@ -28,6 +33,7 @@ public class LogManageService : IAutoInjection
/// <param name="method">方法名称</param>
public void WriteMsg(string tag, string message, int level, int allotId, string method, bool isDebug = false)
{
logger.LogInformation($"method:{method};tag:{tag}; message:{message}; level:{level}");
hubContext.Clients.Group(allotId.ToString()).SendAsync(method, tag, message, level);
if (isDebug)
{
......
......@@ -440,9 +440,12 @@ public void AddItems(int moduleId)
throw new PerformanceException($"医院配置信息未设置");
}
var connection = ConnectionBuilder.Create(DatabaseType.SqlServer, hospitalConfig.DbSource, hospitalConfig.DbName, hospitalConfig.DbUser, hospitalConfig.DbPassword);
logger.LogInformation("创建数据库连接");
var connection = ConnectionBuilder.Create(DatabaseType.Oracle, hospitalConfig.DbSource, hospitalConfig.DbName, hospitalConfig.DbUser, hospitalConfig.DbPassword);
string sql = sqlconfig.Content;
logger.LogInformation($"执行sql:{sql}");
var dataList = perforExtractRepository.ExecuteScript(connection, sql, null);
logger.LogInformation($"获取数据{dataList?.Count ?? 0}条");
if (dataList != null && dataList.Any())
{
var itemList = dataList.Select(t => new mod_item
......
......@@ -88,7 +88,13 @@ public List<SecondListResponse> GetSecondList(int userId)
throw new NotImplementedException("该医院未生成绩效");
var allotListId = allotList.Select(t => t.ID).ToList();
var secondList = perforAgsecondallotRepository.GetEntities(t => allotListId.Contains(t.AllotId.Value) && t.Department == user.Department);
Expression<Func<ag_secondallot, bool>> exp = t => allotListId.Contains(t.AllotId.Value) && t.Department == user.Department;
if (role.RoleID == application.NurseRole)
exp = exp.And(t => t.UnitType == "护理组");
else
exp = exp.And(t => t.UnitType != "护理组");
var secondList = perforAgsecondallotRepository.GetEntities(exp);
//各科室绩效分配结果
var accountList = perforResaccountRepository.GetEntities(t => allotListId.Contains(t.AllotID.Value) && t.Department == user.Department);
//取得未生成二次绩效的绩效id
......
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