Commit 6a000306 by ruyun.zhang@suvalue.com

Merge remote-tracking branch 'origin/feature/new_report' into feature/new_report

parents 3abb61e8 c02a7144
......@@ -48,7 +48,7 @@ public ApiResponse Info([FromBody]SelectionRequest report)
[HttpPost]
public ApiResponse Search([FromBody]SearchReportRequest report)
{
var result = reportDataService.GetReportData(report.HospitalId, report.GroupId, report.ReportId, report.Values);
var result = reportDataService.GetReportData(report.HospitalId, report.GroupId, report.ReportId, report.Values ?? new List<SelectionValues>());
return new ApiResponse(ResponseType.OK, result);
}
......
......@@ -104,10 +104,11 @@ public List<ReportData> GetReportData(int hospitalId, int groupId, int reportId,
var formats = GetParameterFormats();
var groupSelections = groupselectionRepository.GetEntities(w => w.GroupId == groupId);
var arr2 = groupSelections.Select(w => w.SelectionId);
var arr2 = groupSelections?.Select(w => w.SelectionId) ?? new List<int?>();
var dispaly = new int[] { (int)SelectionState.UsableAndDispaly, (int)SelectionState.UsableAndNotDispaly };
var selections = selectionRepository.GetEntities(w => arr2.Contains(w.ID) && w.State.HasValue && dispaly.Contains(w.State.Value));
var selections = selectionRepository.GetEntities(w => arr2.Contains(w.ID) && w.State.HasValue && dispaly.Contains(w.State.Value))
?? new List<rep_selection>();
List<ReportData> result = new List<ReportData>();
foreach (var report in reports)
......@@ -115,8 +116,12 @@ public List<ReportData> GetReportData(int hospitalId, int groupId, int reportId,
var sql = report.Content.ToLower();
//不重复条件,动态拼接WHERE条件
string @where = "";
if (selections != null && selections.Any())
{
selections = GetNoRepeatSelections(sql, formats, selections);
string @where = GetFilterSelection(selections, values);
@where = GetFilterSelection(selections, values);
}
@where += $" and hospitalid={hospitalId}";
// 固定占位符
var pairs = PredefinePlaceholder(values);
......@@ -152,6 +157,8 @@ public List<ReportData> GetReportData(int hospitalId, int groupId, int reportId,
private string GetFilterSelection(List<rep_selection> selections, List<SelectionValues> values)
{
string where = "";
if (values == null || !values.Any())
return where;
foreach (var selection in selections)
{
var value = values.FirstOrDefault(w => w.Title == selection.InputName)?.Values;
......@@ -302,7 +309,7 @@ private string ReplacePlaceholder(List<rep_selection> selections, List<Selection
{
foreach (var selection in selections)
{
var value = values.FirstOrDefault(w => w.Title == selection.InputName).Values;
var value = values.FirstOrDefault(w => w.Title == selection.InputName)?.Values;
if (value == null || !value.Any())
continue;
foreach (var pattern in formats)
......
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