Commit 05379d2e by ruyun.zhang@suvalue.com

合并梧州

parents c260facc 9dc0c4ab
......@@ -92,7 +92,6 @@ public void ConfigureServices(IServiceCollection services)
services.AddSignalR(hubOptions =>
{
hubOptions.EnableDetailedErrors = true;
hubOptions.KeepAliveInterval = TimeSpan.FromMinutes(1);
});
// cors
......@@ -141,7 +140,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
endpoints.MapHub<AllotLogHub>("/performance/allotLogHub", options =>
{
options.Transports = HttpTransportType.WebSockets | HttpTransportType.LongPolling;
options.WebSockets.CloseTimeout = TimeSpan.FromMinutes(1);
options.WebSockets.CloseTimeout = TimeSpan.FromMinutes(20);
});
endpoints.MapControllers();
});
......
......@@ -3684,6 +3684,11 @@
语句执行完成所需时间
</summary>
</member>
<member name="P:Performance.EntityModels.ex_script.IsOrgDepartment">
<summary>
是否使用原始科室 1 是 2 否
</summary>
</member>
<member name="T:Performance.EntityModels.ex_special">
<summary>
......
......@@ -59,5 +59,10 @@ public class ex_script
/// 语句执行完成所需时间
/// </summary>
public decimal TimeConsuming { get; set; } = 0;
/// <summary>
/// 是否使用原始科室 1 是 2 否
/// </summary>
public int IsOrgDepartment { get; set; }
}
}
......@@ -112,14 +112,14 @@ public void DefaultModules(int hospitalId)
public ex_module AddModule(ModModuleRequest request)
{
if (!new int[] { (int)SheetType.Income, (int)SheetType.OtherWorkload, (int)SheetType.Assess }.Contains(request.SheetType.Value))
if (!new int[] { (int)SheetType.Income, (int)SheetType.OtherIncome, (int)SheetType.OtherWorkload, (int)SheetType.Assess }.Contains(request.SheetType.Value))
throw new PerformanceException("模块类型错误,只支持收入模板配置");
string addname = "";
if (request.SheetType == (int)SheetType.Income)
{
if (request.ModuleName.IndexOf("开单收入") == -1 && request.ModuleName.IndexOf("就诊收入") == -1 && request.ModuleName.IndexOf("执行收入") == -1)
throw new PerformanceException("模块名称规则错误");
//if (request.ModuleName.IndexOf("开单收入") == -1 && request.ModuleName.IndexOf("就诊收入") == -1 && request.ModuleName.IndexOf("执行收入") == -1)
// throw new PerformanceException("模块名称规则错误");
//if (!Regex.IsMatch(request.ModuleName, @"^[\u4e00-\u9fa5]+$"))
// throw new PerformanceException("模块名称规则错误,请使用全中文命名");
......@@ -172,7 +172,10 @@ public ex_module AddModule(ModModuleRequest request)
sort[1] += 1;
addname = $"{sort[0]}.{sort[1]} " + request.ModuleName;
}
else
{
addname = request.ModuleName;
}
ex_module entity = new ex_module
{
ModuleName = addname,
......
......@@ -54,8 +54,31 @@ public static void CreateNotExistSheet(List<ex_module> modulesList, IWorkbook wo
try
{
//foreach (var module in modulesList.Where(t => t.SheetType == (int)SheetType.Income)?.OrderBy(t => t.ModuleName))
//{
// var sheet = workbook.GetSheet(module.ModuleName) ?? workbook.GetSheet(module.ModuleName.NoBlank());
// if (sheet == null)
// {
// string[] keyArray = new string[] { "开单", "就诊", "执行" };
// if (keyArray.Any(key => module.ModuleName.Contains(key)))
// {
// var item = pairs.Where(t => t.Key.ToString().NoBlank().StartsWith("1.")).OrderByDescending(t => t.Key).First();
// var copysheet = workbook.GetSheet(item.Key);
// if (copysheet == null) continue;
// try
// {
// var newSheet = copysheet.CopySheet(module.ModuleName, true);
// workbook.SetSheetOrder(newSheet.SheetName, workbook.NumberOfSheets - 1);
// }
// catch (Exception)
// {
// }
// }
// }
//}
var sheetNames = workbook.GetAllNames().Select(w => w.SheetName);
foreach (var module in modulesList.Where(t => t.SheetType == (int)SheetType.Income)?.OrderBy(t => t.ModuleName))
foreach (var module in modulesList.Where(t => new int[] { (int)SheetType.Income, (int)SheetType.OtherIncome }.Contains(t.SheetType.Value))?.OrderBy(t => t.ModuleName))
{
var no = module.ModuleName.GetNo();
var name = sheetNames.FirstOrDefault(name => name.StartsWith(no)) ?? module.ModuleName;
......@@ -63,18 +86,35 @@ public static void CreateNotExistSheet(List<ex_module> modulesList, IWorkbook wo
if (sheet == null)
{
string[] keyArray = new string[] { "开单", "就诊", "执行" };
if (keyArray.Any(key => name.Contains(key)))
{
var item = pairs.Where(t => t.Key.ToString().NoBlank().StartsWith("1.")).OrderByDescending(t => t.Key).First();
var copysheet = workbook.GetSheet(item.Key);
if (copysheet == null) continue;
var newSheet = copysheet.CopySheet(name, true);
ExcelStyle style = new ExcelStyle(workbook);
var cellStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.列头, CellFormat.默认);
var item = pairs.Where(t => t.Key.ToString().NoBlank().StartsWith("1.0.")).OrderByDescending(t => t.Key).First();
var newSheet = workbook.CreateSheet(module.ModuleName);
newSheet.GetOrCreate(1).GetOrCreate(6).SetCellValue("护理组分割比例:");
newSheet.GetOrCreate(1).GetOrCreate(6).CellStyle = cellStyle;
newSheet.GetOrCreate(2).GetOrCreate(6).SetCellValue("医生组分割比例:");
newSheet.GetOrCreate(2).GetOrCreate(6).CellStyle = cellStyle;
newSheet.GetOrCreate(3).GetOrCreate(6).SetCellValue("医技组分割比例:");
newSheet.GetOrCreate(3).GetOrCreate(6).CellStyle = cellStyle;
var r5 = newSheet.GetOrCreate(4);
r5.GetOrCreate(0).SetCellValue("核算收入(医技组)");
r5.GetOrCreate(1).SetCellValue("核算收入(医生组)");
r5.GetOrCreate(2).SetCellValue("核算收入(护理组)");
r5.GetOrCreate(3).SetCellValue("核算单元(医技组)");
r5.GetOrCreate(4).SetCellValue("核算单元(医生组)");
r5.GetOrCreate(5).SetCellValue("核算单元(护理组)");
r5.GetOrCreate(6).SetCellValue("科室名称");
r5.GetOrCreate(0).CellStyle = cellStyle;
r5.GetOrCreate(1).CellStyle = cellStyle;
r5.GetOrCreate(2).CellStyle = cellStyle;
r5.GetOrCreate(3).CellStyle = cellStyle;
r5.GetOrCreate(4).CellStyle = cellStyle;
r5.GetOrCreate(5).CellStyle = cellStyle;
r5.GetOrCreate(6).CellStyle = cellStyle;
workbook.SetSheetOrder(newSheet.SheetName, workbook.NumberOfSheets - 1);
}
}
}
foreach (var module in modulesList.Where(t => new int[] { (int)SheetType.OtherWorkload, (int)SheetType.Assess }.Contains(t.SheetType.Value))?.OrderBy(t => t.ModuleName))
{
var no = module.ModuleName.GetNo();
......@@ -93,7 +133,7 @@ public static void CreateNotExistSheet(List<ex_module> modulesList, IWorkbook wo
}
}
}
catch
catch (Exception ex)
{
}
}
......
......@@ -131,8 +131,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
{
dataFirstRowNum = point.DataFirstRowNum.Value;
RemoveIncomeRow(sheet, point);
WriteSheetIncomeData(sheet, columnHeader, point, style, headers, data, rows, dataFirstRowNum);
dataFirstRowNum = point.DataFirstRowNum.Value + rows.Count;
var endRowNum = WriteSheetIncomeData(sheet, columnHeader, point, style, headers, data, rows, dataFirstRowNum);
dataFirstRowNum = endRowNum;
}
if (data == null || !data.Any()) return;
......@@ -180,10 +180,10 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
if (string.IsNullOrEmpty(column)) continue;
var value = deptData.FirstOrDefault(t => t.Category.NoBlank() == column)?.Value;
//数据为空,且单元格值不为空,不写入数据(保留原始值)
if (value.HasValue && value != 0)
// 22.3.29 ry 只要是提取的列头全部覆盖数据
if (headers != null && headers.Contains(column) && value.HasValue && value != 0)
{
cell.SetCellValue<decimal>(value);
if (headers != null && headers.Contains(column))
cell.CellStyle = cellStyle;
}
......@@ -194,6 +194,7 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
//if (point.DataFirstRowNum.Value < dataFirstRowNum) dataFirstRowNum += 1;
}
}
private static void WriteSheetDataNonexistent(ISheet sheet, IRow columnHeader, PerSheetPoint point, SheetType sheetType, ExcelStyle style,
List<string> headers, List<ExtractTransDto> data, int dataFirstRowNum)
......@@ -223,24 +224,28 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
foreach (string department in departments)
{
var deptData = data.Where(t => (t.Department ?? "") == department);
if (deptData != null && deptData.Any())
{
var row = sheet.GetOrCreate(dataFirstRowNum);
for (int cellIndex = point.HeaderFirstCellNum.Value; cellIndex < columnHeader.LastCellNum; cellIndex++)
{
var column = columnHeader.GetCell(cellIndex).GetDecodeEscapes()?.Replace("(", "(").Replace(")", ")");
var column = columnHeader.GetCell(cellIndex).GetDecodeEscapes();
List<string> uts = new List<string> { "核算单元(医技组)", "核算单元(医生组)", "核算单元(护理组)" };
if (uts.Contains(column))
column = column?.Replace("(", "(").Replace(")", ")");
var cell = row.CreateCell(cellIndex);
if (filed.ContainsKey(column))
{
var value = (deptData != null && deptData.Any()) ? filed[column]?.Invoke(deptData.First()) : "";
var value = filed[column]?.Invoke(deptData.First());
cell.SetCellOValue(value);
cell.CellStyle = cellStyle;
}
else if (sheetType == SheetType.Income || (headers != null && headers.Contains(column)))
{
var value = (deptData != null && deptData.Any())
? deptData.FirstOrDefault(t => t.Category.NoBlank() == column)?.Value
: 0;
var value = deptData.FirstOrDefault(t => t.Category.NoBlank() == column)?.Value;
cell.SetCellValue<decimal>(value);
cell.CellStyle = cellStyle;
}
......@@ -248,8 +253,9 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
dataFirstRowNum++;
}
}
}
private static void WriteSheetIncomeData(ISheet sheet, IRow columnHeader, PerSheetPoint point, ExcelStyle style, List<string> headers,
private static int WriteSheetIncomeData(ISheet sheet, IRow columnHeader, PerSheetPoint point, ExcelStyle style, List<string> headers,
List<ExtractTransDto> data, List<IncomeRow> incomes, int dataFirstRowNum)
{
var cellStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.数据);
......@@ -286,23 +292,29 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
cell.SetCellValue(content.Value);
cell.CellStyle = cellStyle;
}
}
for (int cellIndex = dataFirstCellNum; cellIndex < columnHeader.LastCellNum; cellIndex++)
{
var column = columnHeader.GetOrCreate(cellIndex).GetDecodeEscapes();
var cell = row.GetOrCreate(cellIndex);
var value = deptData.FirstOrDefault(t => t.Category.NoBlank() == column)?.Value;
if (value.HasValue && value != 0)
var value = (deptData != null && deptData.Any())
? deptData.FirstOrDefault(t => t.Category.NoBlank() == column)?.Value
: 0;
//if (cell.CellType != CellType.Formula)
//{
// cell.SetCellValue<decimal>(value);
// cell.CellStyle = cellStyle;
//}
cell.SetCellValue<decimal>(value);
cell.CellStyle = cellStyle;
}
dataFirstRowNum++;
data.RemoveAll(t => t.Department == item.Department);
}
}
return dataFirstRowNum;
}
public static string HasValue(params string[] list)
{
......
......@@ -79,10 +79,11 @@ public void Execute()
if (allot == null || allot.ID == 0) continue;
var dict = new Dictionary<ExDataDict, object>();
var scripts = new List<ex_script>();
var isSingle = hospital.IsSingleProject == 1;
dictionaryService.Handler(hospital.ID, allot, "", isSingle);
var data = queryService.Handler(hospital.ID, allot, "", isSingle, ref dict);
var data = queryService.Handler(hospital.ID, allot, "", isSingle, ref dict, ref scripts);
}
catch (Exception ex)
{
......
......@@ -97,6 +97,7 @@ public string Main(int allotId, int hospitalId, string email, string groupName,
allot = allots.First(t => t.ID == allotId);
var dict = new Dictionary<ExDataDict, object>();
var scripts = new List<ex_script>();
logService.ReturnTheLog(allotId, groupName, 3, "", 5, 1, isSingle);
......@@ -106,8 +107,8 @@ public string Main(int allotId, int hospitalId, string email, string groupName,
employeeService.SyncDataToResult(allotId);
var data = exresultRepository.GetEntities(t => t.AllotId == allotId);
data.AddRange(queryService.Handler(hospitalId, allot, groupName, isSingle, ref dict));
var standData = StandDataFormat(hospitalId, allotId, data);
data.AddRange(queryService.Handler(hospitalId, allot, groupName, isSingle, ref dict, ref scripts));
var standData = StandDataFormat(hospitalId, allotId, scripts, data);
dictionaryService.Handler(hospitalId, allot, groupName, isSingle);
......@@ -279,7 +280,7 @@ private object GetDataBySheetType(int hospitalId, SheetType sheetType, List<Extr
/// <param name="hospitalId"></param>
/// <param name="results"></param>
/// <returns></returns>
private List<ExtractTransDto> StandDataFormat(int hospitalId, int allotId, List<ex_result> results)
private List<ExtractTransDto> StandDataFormat(int hospitalId, int allotId, List<ex_script> scripts, List<ex_result> results)
{
if (results == null || !results.Any()) return new List<ExtractTransDto>();
......@@ -306,51 +307,53 @@ private List<ExtractTransDto> StandDataFormat(int hospitalId, int allotId, List<
dict.ForEach(t =>
{
t.HISDeptName = WriteDataHelper.HasValue(t.HISDeptName, t.Department);
t.Department = WriteDataHelper.HasValue(t.Department, t.HISDeptName);
});
var data = new List<ExtractTransDto>();
foreach (var item in results)
var data = results
.GroupJoin(dict, outer => new { Department = outer.Department }, inner => new { Department = inner.HISDeptName }, (outer, inner) => new { outer, inner })
.Select(t =>
{
var firstDic = dict.FirstOrDefault(w => w.HISDeptName == item.Department) ?? dict.FirstOrDefault(w => w.Department == item.Department);
var dept = !string.IsNullOrEmpty(firstDic?.Department) ? firstDic?.Department : item.Department;
var d = new ExtractTransDto
var dept = !string.IsNullOrEmpty(t.inner.FirstOrDefault()?.Department) ? t.inner.FirstOrDefault()?.Department : t.outer.Department;
if (scripts.Any(w => w.TypeId == t.outer.TypeId && w.IsOrgDepartment == 1))
dept = t.outer.Department;
return new ExtractTransDto
{
SheetName = item.Source,
SheetName = t.outer.Source,
Department = dept,
Category = item.Category,
DoctorName = item.DoctorName,
PersonnelNumber = item.PersonnelNumber,
Value = item.Fee ?? 0,
OutDoctorAccounting = firstDic?.OutDoctorAccounting?.AccountingUnit,
OutNurseAccounting = firstDic?.OutNurseAccounting?.AccountingUnit,
OutTechnicAccounting = firstDic?.OutTechnicAccounting?.AccountingUnit,
InpatDoctorAccounting = firstDic?.InpatDoctorAccounting?.AccountingUnit,
InpatNurseAccounting = firstDic?.InpatNurseAccounting?.AccountingUnit,
InpatTechnicAccounting = firstDic?.InpatTechnicAccounting?.AccountingUnit,
SpecialAccounting = firstDic?.SpecialAccounting?.AccountingUnit ?? dept,
EName = types.FirstOrDefault(w => w.Id == item.TypeId)?.EName,
Category = t.outer.Category,
DoctorName = t.outer.DoctorName,
PersonnelNumber = t.outer.PersonnelNumber,
Value = t.outer.Fee ?? 0,
OutDoctorAccounting = t.inner.FirstOrDefault(f => f.Department == dept)?.OutDoctorAccounting?.AccountingUnit,
OutNurseAccounting = t.inner.FirstOrDefault(f => f.Department == dept)?.OutNurseAccounting?.AccountingUnit,
OutTechnicAccounting = t.inner.FirstOrDefault(f => f.Department == dept)?.OutTechnicAccounting?.AccountingUnit,
InpatDoctorAccounting = t.inner.FirstOrDefault(f => f.Department == dept)?.InpatDoctorAccounting?.AccountingUnit,
InpatNurseAccounting = t.inner.FirstOrDefault(f => f.Department == dept)?.InpatNurseAccounting?.AccountingUnit,
InpatTechnicAccounting = t.inner.FirstOrDefault(f => f.Department == dept)?.InpatTechnicAccounting?.AccountingUnit,
SpecialAccounting = t.inner.FirstOrDefault(f => f.Department == dept)?.SpecialAccounting?.AccountingUnit ?? dept,
EName = types.FirstOrDefault(w => w.Id == t.outer.TypeId)?.EName,
};
data.Add(d);
}
var groupdata = data.GroupBy(t => new { t.Department, t.Category, t.SheetName })
.Select(t => new ExtractTransDto
});
var groupdata = data.GroupBy(t => new { t.Department, t.Category, t.SheetName }).Select(t => new ExtractTransDto
{
SheetName = t.Key.SheetName,
Department = t.Key.Department,
Category = t.Key.Category,
Value = t.Sum(group => group.Value) == 0 ? null : t.Sum(group => group.Value),
OutDoctorAccounting = t.FirstOrDefault(w => !string.IsNullOrEmpty(w.OutDoctorAccounting))?.OutDoctorAccounting,
OutNurseAccounting = t.FirstOrDefault(w => !string.IsNullOrEmpty(w.OutNurseAccounting))?.OutNurseAccounting,
OutTechnicAccounting = t.FirstOrDefault(w => !string.IsNullOrEmpty(w.OutTechnicAccounting))?.OutTechnicAccounting,
InpatDoctorAccounting = t.FirstOrDefault(w => !string.IsNullOrEmpty(w.InpatDoctorAccounting))?.InpatDoctorAccounting,
InpatNurseAccounting = t.FirstOrDefault(w => !string.IsNullOrEmpty(w.InpatNurseAccounting))?.InpatNurseAccounting,
InpatTechnicAccounting = t.FirstOrDefault(w => !string.IsNullOrEmpty(w.InpatTechnicAccounting))?.InpatTechnicAccounting,
SpecialAccounting = t.FirstOrDefault(w => !string.IsNullOrEmpty(w.SpecialAccounting))?.SpecialAccounting,
OutDoctorAccounting = t.FirstOrDefault()?.OutDoctorAccounting,
OutNurseAccounting = t.FirstOrDefault()?.OutNurseAccounting,
OutTechnicAccounting = t.FirstOrDefault()?.OutTechnicAccounting,
InpatDoctorAccounting = t.FirstOrDefault()?.InpatDoctorAccounting,
InpatNurseAccounting = t.FirstOrDefault()?.InpatNurseAccounting,
InpatTechnicAccounting = t.FirstOrDefault()?.InpatTechnicAccounting,
SpecialAccounting = t.FirstOrDefault()?.SpecialAccounting,
EName = t.FirstOrDefault(w => !string.IsNullOrEmpty(w.EName))?.EName
});
return groupdata.ToList();
return groupdata.Where(w => w.Value.HasValue && w.Value != 0).ToList();
}
private void UpdateAllot(IDbConnection connection, per_allot allot)
......
......@@ -75,7 +75,7 @@ public void ClearConnectionPools()
/// <param name="hospitalId"></param>
/// <param name="allot"></param>
/// <returns></returns>
public List<ex_result> Handler(int hospitalId, per_allot allot, string groupName, bool isSingle, ref Dictionary<ExDataDict, object> dict)
public List<ex_result> Handler(int hospitalId, per_allot allot, string groupName, bool isSingle, ref Dictionary<ExDataDict, object> dict, ref List<ex_script> scripts)
{
try
{
......@@ -97,7 +97,7 @@ public List<ex_result> Handler(int hospitalId, per_allot allot, string groupName
logService.ReturnTheLog(allot.ID, groupName, 2, "提取数据", $"开始提取数据", isSingle: isSingle);
var scripts = exscriptRepository.GetEntities(t => extypeIds.Contains(t.TypeId));
scripts = exscriptRepository.GetEntities(t => extypeIds.Contains(t.TypeId));
if (scripts != null && scripts.Any())
{
var allmodules = dict[ExDataDict.ExModule] as List<ex_module>;
......
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