调整进入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

@@ -824,6 +824,22 @@ public static class StringExtensions
return char.ToUpper(str[0]) + str.Substring(1, str.Length - 1); return char.ToUpper(str[0]) + str.Substring(1, str.Length - 1);
} }
/// <summary>
/// Span实现首字符大写
/// added by ly on 20230407
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public static string FirstCharToUpperAsSpan(this string input)
{
if (string.IsNullOrEmpty(input))
{
return string.Empty;
}
Span<char> destination = stackalloc char[1];
input.AsSpan(0, 1).ToUpperInvariant(destination);
return $"{destination}{input.AsSpan(1)}";
}
/// <summary> /// <summary>
/// 计算当前字符串与指定字符串的编辑距离(相似度). /// 计算当前字符串与指定字符串的编辑距离(相似度).

View File

@@ -1,6 +1,7 @@
using System.Collections; using System.Collections;
using System.Data; using System.Data;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using JNPF.Common.Configuration; using JNPF.Common.Configuration;
using JNPF.Common.Core.Manager; using JNPF.Common.Core.Manager;
using JNPF.Common.Core.Manager.Files; using JNPF.Common.Core.Manager.Files;
@@ -356,7 +357,7 @@ public class DataBaseService : IDynamicApiController, ITransient
/// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentNullException"></exception>
/// <exception cref="ArgumentException"></exception> /// <exception cref="ArgumentException"></exception>
[HttpPost("{linkId}/gen-code")] [HttpPost("{linkId}/gen-code")]
public async Task<dynamic> GenerateCode(string linkId,DatabaseTableDataCleanInput input) public async Task<dynamic> GenerateCode(string linkId, DatabaseTableDataCleanInput input)
{ {
if (input.TableName.IsNullOrWhiteSpace()) if (input.TableName.IsNullOrWhiteSpace())
{ {
@@ -386,11 +387,24 @@ public class DataBaseService : IDynamicApiController, ITransient
{ {
var pos = 0; var pos = 0;
if ((pos = s.IndexOf("_", StringComparison.Ordinal)) > -1) if ((pos = s.IndexOf("_", StringComparison.Ordinal)) > -1)
{
var separatorStrings = Regex.Split(s, @"_", RegexOptions.Compiled);
if (separatorStrings.Length > 2)
{
var sb = new StringBuilder();
foreach (var item in separatorStrings)
{
sb.Append(item.ToUpperCase());
}
return sb.ToString();
}
else
{ {
var first = s.AsSpan().Slice(0, pos).ToString().ToUpperCase(); var first = s.AsSpan().Slice(0, pos).ToString().ToUpperCase();
var second = s.AsSpan().Slice(pos + 1).ToString().ToUpperCase(); var second = s.AsSpan().Slice(pos + 1).ToString().ToUpperCase();
return $"{first}{second}"; return $"{first}{second}";
} }
}
else else
{ {
return s.ToUpperCase(); return s.ToUpperCase();

View File

@@ -1,4 +1,5 @@
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using JNPF.Common.Const; using JNPF.Common.Const;
using JNPF.Common.Core.Manager; using JNPF.Common.Core.Manager;
using JNPF.Common.Dtos.VisualDev; 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())) 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); 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 else //modified by ly on 20230407
realList.list = await _formDataParsing.GetKeyData(templateInfo.SingleFormData.Where(x => x.__config__.templateJson == null).ToList(), realList.list, templateInfo.ColumnData, actionType, templateInfo.WebType, primaryKey); 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()) 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))) 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 (!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 (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]; 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 oldTInfo = new TemplateParsingBase(oldFEntity.PropertyJson, oldFEntity.TableJson, (int)oldFEntity.FormType); // 旧模板
var newTInfo = new TemplateParsingBase(newFEntity.PropertyJson, newFEntity.TableJson, (int)newFEntity.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 => oldTInfo.AllFieldsModel.ForEach(it =>
{ {
@@ -2378,7 +2379,7 @@ public class RunService : IRunService, ITransient
else newItem.ConditionalList.RemoveAt(j); else newItem.ConditionalList.RemoveAt(j);
} }
if(newItem.ConditionalList.Any()) cList[i] = newItem; if (newItem.ConditionalList.Any()) cList[i] = newItem;
else cList.RemoveAt(i); else cList.RemoveAt(i);
} }
else if (cList[i] is ConditionalModel) else if (cList[i] is ConditionalModel)
@@ -2865,8 +2866,8 @@ public class RunService : IRunService, ITransient
break; break;
case JnpfKeyConst.SELECT: case JnpfKeyConst.SELECT:
{ {
//modified by ly on 20230407
var itemValue = item.Value.ToString().Contains("[") ? item.Value.ToJsonString() : item.Value.ToString(); var itemValue = item.Value.ToString().Contains("[") ? item.Value.ToJsonString() : item.Value.ToString();
//modified by ly on 20230407
JArray jarr = null; JArray jarr = null;
if (itemValue!.Contains("[")) 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(); var condition = new ConditionalCollections();
condition.ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>(values.Count); 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, FieldName = item.Key,
ConditionalType = ConditionalType.Equal, ConditionalType = ConditionalType.Equal,
FieldValue = itemValue FieldValue = x,
}); }));
}); });
conModels.Add(condition); conModels.Add(condition);
} }
else else
{ {
//modified by ly on 20230407
itemValue = Regex.Match(itemValue, @"\[(.+)\]").Groups[1].Value;
itemValue = itemValue.Trim('"');
conModels.Add(new ConditionalCollections() conModels.Add(new ConditionalCollections()
{ {
ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>() ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
@@ -3134,7 +3139,7 @@ public class RunService : IRunService, ITransient
var datas = new List<Dictionary<string, object>>(); var datas = new List<Dictionary<string, object>>();
if (childTableModel.__config__.children.Any(x => x.__config__.templateJson != null && x.__config__.templateJson.Any())) 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); datas = await _formDataParsing.GetKeyData(childTableModel.__config__.children.Where(x => x.__config__.templateJson == null).ToList(), rows, templateInfo.ColumnData);
var newDatas = datas.Copy(); var newDatas = datas.Copy();
newDatas.ForEach(x => x.Remove(relationField[item.Key])); newDatas.ForEach(x => x.Remove(relationField[item.Key]));