调整框架多组合代码,组合条件查询

This commit is contained in:
DEVICE8\12494
2023-04-27 18:40:38 +08:00
parent 70cac6bc83
commit 264f03bb15
6 changed files with 51 additions and 41 deletions

View File

@@ -176,12 +176,25 @@ public class RunService : IRunService, ITransient
input.superQueryJson = GetSuperQueryJson(input.superQueryJson).ToJsonString();
//modified by ly on 20230426
if (!input.station_code.IsNullOrWhiteSpace())
var jArr = JArray.Parse(entity.Tables);
if (!input.station_code.IsNullOrWhiteSpace())
{
sql += $" where station_code='{input.station_code}' or station_code=''";
if (jArr?.FirstOrDefault()?.Value<string>("table") == "eqp_equipment")
{
sql += $" where station_code='{input.station_code}' or station_code=''";
}
}
if (!input.process_code.IsNullOrWhiteSpace())
{
if (jArr?.FirstOrDefault()?.Value<string>("table") == "bas_process")
{
//sql += $" where station_code='{input.station_code}' or station_code=''";
}
}
realList = _databaseService.GetInterFaceData(link, sql, input, templateInfo.ColumnData.Adapt<MainBeltViceQueryModel>(), new List<IConditionalModel>(), tableFieldKeyValue);
realList = _databaseService.GetInterFaceData(link, sql, input, templateInfo.ColumnData.Adapt<MainBeltViceQueryModel>(), new List<IConditionalModel>(), tableFieldKeyValue);
// 显示列有子表字段
@@ -1565,7 +1578,7 @@ public class RunService : IRunService, ITransient
{
List<FieldsModel> childFieldsModelList = model.__config__.children;
object? objectData = allDataMap[strKey[i]];
List<Dictionary<string, object>> childAllDataMapList = objectData.ToJsonString().ToObject<List<Dictionary<string, object>>>();
if (childAllDataMapList != null && childAllDataMapList.Count > 0)
{
@@ -2889,27 +2902,17 @@ public class RunService : IRunService, ITransient
{
jarr = JArray.Parse(itemValue);
}
// 多选时为模糊查询
if (model.multiple)
{
if (jarr?.Children() != null && jarr?.Children().ToList().Count > 1)
{
var values = jarr.ToList().Select(t => t.Value<string>()).ToList();
var condition = new ConditionalCollections();
condition.ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>(values.Count);
values.ForEach(x =>
{
condition.ConditionalList.Add(new KeyValuePair<WhereType, ConditionalModel>(WhereType.Or, new ConditionalModel
{
FieldName = item.Key,
ConditionalType = ConditionalType.Like,
FieldValue = x,
}));
});
conModels.Add(condition);
var values = string.Join(",", jarr.ToList().Select(t => t.Value<string>()));
conModels.Add(new ConditionalModel { FieldName= item.Key, ConditionalType= ConditionalType.In, FieldValue=values });
}
else
else
{
conModels.Add(new ConditionalCollections()
{
@@ -2924,34 +2927,24 @@ public class RunService : IRunService, ITransient
}
});
}
}
//modified by ly on 20230407
else if (jarr?.Children() != null && jarr?.Children().ToList().Count > 1)
{
var values = jarr.ToList().Select(t => t.Value<string>()).ToList();
var condition = new ConditionalCollections();
condition.ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>(values.Count);
values.ForEach(x =>
{
condition.ConditionalList.Add(new KeyValuePair<WhereType, ConditionalModel>(WhereType.Or, new ConditionalModel
{
FieldName = item.Key,
ConditionalType = ConditionalType.Equal,
FieldValue = x,
}));
});
conModels.Add(condition);
var values = string.Join(",", jarr.ToList().Select(t => t.Value<string>()));
conModels.Add(new ConditionalModel { FieldName = item.Key, ConditionalType = ConditionalType.In, FieldValue = values });
}
else
{
//modified by ly on 20230407
if (itemValue.IsMatch(@"\[(.+)\]"))
if (itemValue.IsMatch(@"\[(.+)\]"))
{
itemValue = Regex.Match(itemValue, @"\[(.+)\]").Groups[1].Value;
itemValue = itemValue.Trim('"');
}
conModels.Add(new ConditionalCollections()
{
ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()