调整进入getKeyData的判断条件

This commit is contained in:
DEVICE8\12494
2023-04-07 17:13:11 +08:00
parent 9d85cceab6
commit adba94e833
3 changed files with 354 additions and 319 deletions

View File

@@ -1,4 +1,5 @@
using System.Text;
using System.Text.RegularExpressions;
using JNPF.Common.Const;
using JNPF.Common.Core.Manager;
using JNPF.Common.Dtos.VisualDev;
@@ -206,8 +207,8 @@ public class RunService : IRunService, ITransient
{
if (templateInfo.SingleFormData.Any(x => x.__config__.templateJson != null && x.__config__.templateJson.Any()))
realList.list = await _formDataParsing.GetKeyData(templateInfo.SingleFormData.Where(x => x.__config__.templateJson != null && x.__config__.templateJson.Any()).ToList(), realList.list, templateInfo.ColumnData, actionType, templateInfo.WebType, primaryKey);
else
realList.list = await _formDataParsing.GetKeyData(templateInfo.SingleFormData.Where(x => x.__config__.templateJson == null).ToList(), realList.list, templateInfo.ColumnData, actionType, templateInfo.WebType, primaryKey);
else //modified by ly on 20230407
realList.list = await _formDataParsing.GetKeyData(templateInfo.SingleFormData.Where(x => x.__config__.templateJson == null|| !x.__config__.templateJson.Any()).ToList(), realList.list, templateInfo.ColumnData, actionType, templateInfo.WebType, primaryKey);
// 如果是无表数据并且排序字段不为空,再进行数据排序
if (!templateInfo.IsHasTable && input.sidx.IsNotEmptyOrNull())
@@ -286,7 +287,7 @@ public class RunService : IRunService, ITransient
if (!newItem.ContainsKey(item.Key.Replace(roweditId, string.Empty))) newItem.Add(item.Key.Replace(roweditId, string.Empty), obj);
if (!newItem.ContainsKey(item.Key.Replace(roweditId, string.Empty) + "_name")) newItem.Add(item.Key.Replace(roweditId, string.Empty) + "_name", value);
}
if(item.Key.Equals("flowState") || item.Key.Equals("flowState_name")) newItem.Add(item.Key, item.Value);
if (item.Key.Equals("flowState") || item.Key.Equals("flowState_name")) newItem.Add(item.Key, item.Value);
if (item.Key.Equals("id") && !newItem.ContainsKey(item.Key)) newItem.Add(item.Key, item.Value);
if (templateInfo.AllFieldsModel.Any(x => x.__vModel__.Equals(item.Key) && x.__config__.jnpfKey.Equals(JnpfKeyConst.TIME))) newItem[item.Key] = items[item.Key];
}
@@ -1111,7 +1112,7 @@ public class RunService : IRunService, ITransient
var oldTInfo = new TemplateParsingBase(oldFEntity.PropertyJson, oldFEntity.TableJson, (int)oldFEntity.FormType); // 旧模板
var newTInfo = new TemplateParsingBase(newFEntity.PropertyJson, newFEntity.TableJson, (int)newFEntity.FormType); // 新模板
if(oldFEntity.FormType.Equals(1) || newFEntity.FormType.Equals(1))
if (oldFEntity.FormType.Equals(1) || newFEntity.FormType.Equals(1))
{
oldTInfo.AllFieldsModel.ForEach(it =>
{
@@ -1733,9 +1734,9 @@ public class RunService : IRunService, ITransient
/// <returns></returns>
private string GetPrimary(DbLinkEntity link, string MainTableName)
{
var keys = _databaseService.GetPrimaries(link, MainTableName);
if (keys.Count < 1) throw Oops.Oh(ErrorCode.D1402); // 主表未设置主键
return keys.First();
var keys = _databaseService.GetPrimaries(link, MainTableName);
if (keys.Count < 1) throw Oops.Oh(ErrorCode.D1402); // 主表未设置主键
return keys.First();
//List<DbTableFieldModel>? tableList = _databaseService.GetFieldList(link, MainTableName); // 获取主表所有列
//DbTableFieldModel? mainPrimary = tableList.Find(t => t.primaryKey); // 主表主键
//if (mainPrimary == null || mainPrimary.IsNullOrEmpty()) throw Oops.Oh(ErrorCode.D1402); // 主表未设置主键
@@ -2378,7 +2379,7 @@ public class RunService : IRunService, ITransient
else newItem.ConditionalList.RemoveAt(j);
}
if(newItem.ConditionalList.Any()) cList[i] = newItem;
if (newItem.ConditionalList.Any()) cList[i] = newItem;
else cList.RemoveAt(i);
}
else if (cList[i] is ConditionalModel)
@@ -2865,8 +2866,8 @@ public class RunService : IRunService, ITransient
break;
case JnpfKeyConst.SELECT:
{
//modified by ly on 20230407
var itemValue = item.Value.ToString().Contains("[") ? item.Value.ToJsonString() : item.Value.ToString();
//modified by ly on 20230407
JArray jarr = null;
if (itemValue!.Contains("["))
{
@@ -2889,24 +2890,28 @@ public class RunService : IRunService, ITransient
}
});
}
else if (jarr?.Children()!= null && jarr?.Children().ToList().Count > 1)
//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 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 =>
values.ForEach(x =>
{
new KeyValuePair<WhereType, ConditionalModel>(WhereType.Or, new ConditionalModel
condition.ConditionalList.Add(new KeyValuePair<WhereType, ConditionalModel>(WhereType.Or, new ConditionalModel
{
FieldName = item.Key,
ConditionalType = ConditionalType.Equal,
FieldValue = itemValue
});
FieldValue = x,
}));
});
conModels.Add(condition);
}
else
{
//modified by ly on 20230407
itemValue = Regex.Match(itemValue, @"\[(.+)\]").Groups[1].Value;
itemValue = itemValue.Trim('"');
conModels.Add(new ConditionalCollections()
{
ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
@@ -3134,7 +3139,7 @@ public class RunService : IRunService, ITransient
var datas = new List<Dictionary<string, object>>();
if (childTableModel.__config__.children.Any(x => x.__config__.templateJson != null && x.__config__.templateJson.Any()))
datas = (await _formDataParsing.GetKeyData(childTableModel.__config__.children.Where(x => x.__config__.templateJson != null && x.__config__.templateJson.Any()).ToList(), rows, templateInfo.ColumnData, "List",2, "F_Id", it));
datas = (await _formDataParsing.GetKeyData(childTableModel.__config__.children.Where(x => x.__config__.templateJson != null && x.__config__.templateJson.Any()).ToList(), rows, templateInfo.ColumnData, "List", 2, "F_Id", it));
datas = await _formDataParsing.GetKeyData(childTableModel.__config__.children.Where(x => x.__config__.templateJson == null).ToList(), rows, templateInfo.ColumnData);
var newDatas = datas.Copy();
newDatas.ForEach(x => x.Remove(relationField[item.Key]));