Commit 4405724b by 李承祥

特殊科室

parent 7f51942a
......@@ -2120,6 +2120,11 @@
只读 0、否 1、是
</summary>
</member>
<member name="P:Performance.EntityModels.mod_item.ConfigId">
<summary>
数据库地址
</summary>
</member>
<member name="T:Performance.EntityModels.mod_module">
<summary>
......@@ -2165,6 +2170,11 @@
是否生成Item 0、否 1、是
</summary>
</member>
<member name="P:Performance.EntityModels.mod_module.ConfigId">
<summary>
数据库地址
</summary>
</member>
<member name="T:Performance.EntityModels.mod_special">
<summary>
......@@ -2200,6 +2210,16 @@
调节系数
</summary>
</member>
<member name="P:Performance.EntityModels.mod_special.ExtractId">
<summary>
抽取绩效值SQL
</summary>
</member>
<member name="P:Performance.EntityModels.mod_special.ConfigId">
<summary>
数据库地址
</summary>
</member>
<member name="T:Performance.EntityModels.per_againallot">
<summary>
......
......@@ -60,5 +60,10 @@ public class mod_item
/// 只读 0、否 1、是
/// </summary>
public Nullable<int> ReadOnly { get; set; }
/// <summary>
/// 数据库地址
/// </summary>
public Nullable<int> ConfigId { get; set; }
}
}
......@@ -55,5 +55,10 @@ public class mod_module
/// 是否生成Item 0、否 1、是
/// </summary>
public Nullable<int> IsGenerated { get; set; }
/// <summary>
/// 数据库地址
/// </summary>
public Nullable<int> ConfigId { get; set; }
}
}
......@@ -45,5 +45,15 @@ public class mod_special
/// 调节系数
/// </summary>
public Nullable<decimal> AdjustFactor { get; set; }
/// <summary>
/// 抽取绩效值SQL
/// </summary>
public Nullable<int> ExtractId { get; set; }
/// <summary>
/// 数据库地址
/// </summary>
public Nullable<int> ConfigId { get; set; }
}
}
......@@ -135,29 +135,29 @@ public string ExtractData(int allotId, string email, int hospitalId)
var sheetRead = PerSheetDataFactory.GetDataRead(sheetType);
switch (sheetType)
{
case SheetType.Employee:
if (allotLast != null)
WriteEmployee(sheet, allotLast.ID, sheetRead);
break;
case SheetType.AccountBasic:
if (allotLast != null)
WriteAccountBasic(sheet, allotLast.ID, sheetRead);
break;
//case SheetType.Employee:
// if (allotLast != null)
// WriteEmployee(sheet, allotLast.ID, sheetRead);
// break;
//case SheetType.AccountBasic:
// if (allotLast != null)
// WriteAccountBasic(sheet, allotLast.ID, sheetRead);
// break;
case SheetType.SpecialUnit:
WriteSpecialUnit(sheet, hospital.ID, allotLast, sheetRead);
break;
case SheetType.Income:
WriteIncome(sheet, hospital.ID, unitList, sheetRead, allot, modulesList, hospitalConfigList);
break;
case SheetType.OtherIncome:
WriteOtherIncome(sheet, hospital.ID, unitList, sheetRead, allot, modulesList, hospitalConfigList);
break;
case SheetType.Expend:
WriteExpend(sheet, hospital.ID, sheetRead);
break;
case SheetType.Workload:
WriteWorkload(sheet, hospital.ID, unitList, sheetRead, allot, modulesList, hospitalConfigList);
WriteSpecialUnit(sheet, hospital.ID, allot, sheetRead, hospitalConfigList);
break;
//case SheetType.Income:
// WriteIncome(sheet, hospital.ID, unitList, sheetRead, allot, modulesList, hospitalConfigList);
// break;
//case SheetType.OtherIncome:
// WriteOtherIncome(sheet, hospital.ID, unitList, sheetRead, allot, modulesList, hospitalConfigList);
// break;
//case SheetType.Expend:
// WriteExpend(sheet, hospital.ID, sheetRead);
// break;
//case SheetType.Workload:
// WriteWorkload(sheet, hospital.ID, unitList, sheetRead, allot, modulesList, hospitalConfigList);
// break;
}
}
using (FileStream file = new FileStream(newPath, FileMode.OpenOrCreate))
......@@ -252,17 +252,30 @@ private void WriteOtherIncome(ISheet sheet, int hospitalId, List<AccountUnitEnti
}
//查询数据
var extractList = perforModextractRepository.GetEntities(t => module.ExtractId == t.Id);
var extractIdList = itemList.Select(t => t.ExtractId).Distinct().ToList();
var extractList = perforModextractRepository.GetEntities(t => extractIdList.Contains(t.Id));
if (extractList == null || extractList.Count == 0) return;
List<ExtractDto> allExtract = new List<ExtractDto>();
foreach (var item in extractList)
{
logManageService.WriteMsg("提取绩效数据", $"执行SQL脚本获取数据 -- {module.ModuleName}", 1, AllotId, "ReceiveMessage");
LogHelper.Information($"执行SQL脚本获取数据 -- {module.ModuleName}", "提取绩效数据");
var result = QueryDatabase(hospitalConfigList, item, allot);
if (result != null)
allExtract.AddRange(result);
var category = itemList.Where(t => t.ExtractId == item.Id);
if (category == null || category.Count() == 0) continue;
foreach (var moditem in category)
{
logManageService.WriteMsg("提取绩效数据", $"执行SQL脚本获取数据 -- {module.ModuleName}", 1, AllotId, "ReceiveMessage");
LogHelper.Information($"执行SQL脚本获取数据 -- {module.ModuleName},", "提取绩效数据");
var result = QueryDatabase(hospitalConfigList, item, allot, moditem.ConfigId ?? 0, moditem.ItemName);
if (result != null)
allExtract.AddRange(result);
}
}
var specialHead = new List<string>();
var extractHead = allExtract?.Select(t => t.Category);
if (extractHead != null && extractHead.Any())
{
specialHead = itemList.Select(t => t.ItemName).Intersect(extractHead.Distinct())?.ToList();
}
logManageService.WriteMsg("提取绩效数据", $"填充数据 -- {module.ModuleName}", 1, AllotId, "ReceiveMessage");
......@@ -357,7 +370,7 @@ private void WriteIncome(ISheet sheet, int hospitalId, List<AccountUnitEntity> u
{
logManageService.WriteMsg("提取绩效数据", $"执行SQL脚本获取数据 -- {module.ModuleName}", 1, AllotId, "ReceiveMessage");
LogHelper.Information($"执行SQL脚本获取数据 -- {module.ModuleName}", "提取绩效数据");
var result = QueryDatabase(hospitalConfigList, item, allot);
var result = QueryDatabase(hospitalConfigList, item, allot, module.ConfigId ?? 0);
if (result != null)
allExtract.AddRange(result);
}
......@@ -480,7 +493,7 @@ private void WriteWorkload(ISheet sheet, int hospitalId, List<AccountUnitEntity>
{
logManageService.WriteMsg("提取绩效数据", $"执行SQL脚本获取数据 -- {module.ModuleName}", 1, AllotId, "ReceiveMessage");
LogHelper.Information($"执行SQL脚本获取数据 -- {module.ModuleName},", "提取绩效数据");
var result = QueryDatabase(hospitalConfigList, item, allot, moditem.ItemName);
var result = QueryDatabase(hospitalConfigList, item, allot, moditem.ConfigId ?? 0, moditem.ItemName);
if (result != null)
allExtract.AddRange(result);
}
......@@ -528,9 +541,10 @@ private void WriteWorkload(ISheet sheet, int hospitalId, List<AccountUnitEntity>
}
}
private List<ExtractDto> QueryDatabase(List<sys_hospitalconfig> hospitalConfigList, mod_extract extract, per_allot allot, string category = null)
private List<ExtractDto> QueryDatabase(List<sys_hospitalconfig> hospitalConfigList, mod_extract extract, per_allot allot, int configId, string category = null)
{
var config = hospitalConfigList.FirstOrDefault(t => t.Type == extract.SourceType);
var config = hospitalConfigList.FirstOrDefault(t => t.Id == configId);
if (config == null) return null;
string executeScript = extract.ExecuteScript;
var parameters = GetParameters(allot);
using (var connection = ConnectionBuilder.Create((DatabaseType)config.DataBaseType, config.DbSource, config.DbName, config.DbUser, config.DbPassword))
......@@ -647,12 +661,12 @@ private void WriteEmployee(ISheet sheet, int allotLastId, IPerSheetDataRead shee
}
}
private void WriteSpecialUnit(ISheet sheet, int hospitalId, per_allot allotLast, IPerSheetDataRead sheetRead)
private void WriteSpecialUnit(ISheet sheet, int hospitalId, per_allot allot, IPerSheetDataRead sheetRead, List<sys_hospitalconfig> hospitalConfigList)
{
var dictionary = new Dictionary<string, Func<mod_special, List<im_specialunit>, object>>
var dictionary = new Dictionary<string, Func<mod_special, List<ExtractDto>, object>>
{
{ "科室", (special,lastAllot) => special.Department },
{ "人数", (special,lastAllot) => lastAllot.Where(t=>special.Department == t.Department).Sum(t=>t.Number) },
{ "人数", (special,lastAllot) => lastAllot.Where(t=>special.Department == t.Department).Sum(t=>t.Value) },
{ "量化指标", (special,lastAllot) => special.Target},
{ "量化指标绩效分值",(special,lastAllot) => special.TargetFactor },
{ "调节系数", (special,lastAllot) => special.AdjustFactor },
......@@ -661,9 +675,29 @@ private void WriteSpecialUnit(ISheet sheet, int hospitalId, per_allot allotLast,
var modDataList = perforModspecialRepository.GetEntities(t => t.HospitalId == hospitalId)?.OrderBy(t => t.Department).ToList();
if (modDataList == null || modDataList.Count == 0) return;
List<im_specialunit> allotDataList = new List<im_specialunit>();
if (allotLast != null)
allotDataList = perforImspecialunitRepository.GetEntities(t => t.AllotID == allotLast.ID);
//List<im_specialunit> allotDataList = new List<im_specialunit>();
//if (allotLast != null)
// allotDataList = perforImspecialunitRepository.GetEntities(t => t.AllotID == allotLast.ID);
//查询数据
var extractIdList = modDataList.Select(t => t.ExtractId).Distinct().ToList();
var extractList = perforModextractRepository.GetEntities(t => extractIdList.Contains(t.Id));
if (extractList == null || extractList.Count == 0) return;
List<ExtractDto> allExtract = new List<ExtractDto>();
foreach (var item in extractList)
{
var category = modDataList.Where(t => t.ExtractId == item.Id);
if (category == null || category.Count() == 0) continue;
foreach (var moditem in category)
{
logManageService.WriteMsg("提取绩效数据", $"执行SQL脚本获取数据 -- 特殊核算单元绩效测算表", 1, AllotId, "ReceiveMessage");
LogHelper.Information($"执行SQL脚本获取数据 -- 特殊核算单元绩效测算表,", "提取绩效数据");
var result = QueryDatabase(hospitalConfigList, item, allot, moditem.ConfigId ?? 0, moditem.Target);
if (result != null)
allExtract.AddRange(result);
}
}
//取消合并单元格
int mergedCount = sheet.NumMergedRegions;
......@@ -701,7 +735,7 @@ private void WriteSpecialUnit(ISheet sheet, int hospitalId, per_allot allotLast,
if (dictionary.ContainsKey(cell.StringCellValue))
{
var item = dictionary.First(t => t.Key == cell.StringCellValue);
value = item.Value.Invoke(modDataList[i], allotDataList) ?? "";
value = item.Value.Invoke(modDataList[i], allExtract) ?? "";
if (item.Key == "科室" && rowIndex == mergedBegin)
{
......
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