merge from 2023-03-14
This commit is contained in:
@@ -15,9 +15,6 @@ using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.RemoteRequest.Extensions;
|
||||
using JNPF.Systems.Entitys.Model.DataInterFace;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Spire.Pdf.Lists;
|
||||
using Senparc.NeuChar.Entities;
|
||||
|
||||
namespace JNPF.Common.CodeGen.DataParsing;
|
||||
|
||||
@@ -43,11 +40,6 @@ public class ControlParsing : ITransient
|
||||
/// </summary>
|
||||
private readonly IDataInterfaceService _dataInterfaceService;
|
||||
|
||||
/// <summary>
|
||||
/// 解析控件的控件属性 (vModel , Attr).
|
||||
/// </summary>
|
||||
private Dictionary<string, FieldsModel>? ControlAttr;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数.
|
||||
/// </summary>
|
||||
@@ -74,9 +66,6 @@ public class ControlParsing : ITransient
|
||||
/// <returns></returns>
|
||||
public async Task<List<Dictionary<string, object>>> GetParsDataList(List<Dictionary<string, object>> oldDatas, string vModelStr, string jnpfKeyConst, string tenantId, List<FieldsModel>? vModelAttr = null)
|
||||
{
|
||||
ControlAttr = new Dictionary<string, FieldsModel>();
|
||||
if (vModelAttr != null) vModelAttr.ForEach(it => ControlAttr.Add(it.__vModel__, it));
|
||||
|
||||
var vModels = new Dictionary<string, object>();
|
||||
var vModelList = vModelStr.Split(',');
|
||||
oldDatas.ForEach(items =>
|
||||
@@ -91,45 +80,54 @@ public class ControlParsing : ITransient
|
||||
var ctOldDatas = item.Value.ToObject<List<Dictionary<string, object>>>();
|
||||
ctOldDatas.ForEach(ctItems =>
|
||||
{
|
||||
foreach (var ctItem in ctItems) if (vModelList.Contains(ctItem.Key) && !vModels.ContainsKey(ctItem.Key)) vModels.Add(ctItem.Key, jnpfKeyConst);
|
||||
foreach (var ctItem in ctItems)
|
||||
{
|
||||
if (vModelList.Contains(item.Key + "-" + ctItem.Key) && !vModels.ContainsKey(item.Key + "-" + ctItem.Key))
|
||||
vModels.Add(item.Key + "-" + ctItem.Key, jnpfKeyConst);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return await GetParsDataByList(oldDatas, vModels, tenantId);
|
||||
return await GetParsDataByList(vModelAttr, oldDatas, vModels, tenantId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取解析数据.
|
||||
/// </summary>
|
||||
/// <param name="fields">模板集合.</param>
|
||||
/// <param name="oldDatas">原数据集合.</param>
|
||||
/// <param name="vModels">需解析的字段 (字段名,JnpfKeyConst/子表dictionary).</param>
|
||||
/// <param name="tenantId">租户Id.</param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<Dictionary<string, object>>> GetParsDataByList(List<Dictionary<string, object>> oldDatas, Dictionary<string, object> vModels, string tenantId)
|
||||
private async Task<List<Dictionary<string, object>>> GetParsDataByList(List<FieldsModel> fields, List<Dictionary<string, object>> oldDatas, Dictionary<string, object> vModels, string tenantId)
|
||||
{
|
||||
var cacheData = await GetCaCheData(vModels, tenantId);
|
||||
var usersselectDatas = cacheData.Where(t => t.Key.Equals(CommonConst.CodeGenDynamic + "_usersSelect_" + tenantId)).FirstOrDefault().Value.ToObject<Dictionary<string, string>>(); // 用户组件
|
||||
|
||||
oldDatas.ForEach(async items =>
|
||||
foreach (var items in oldDatas)
|
||||
{
|
||||
foreach (var item in items)
|
||||
for(var i = 0; i < items.Count; i++)
|
||||
{
|
||||
if (vModels.Any(x => x.Key.Equals(item.Key)))
|
||||
var item = items.ToList()[i];
|
||||
|
||||
if (vModels.Any(x => x.Key.Equals(item.Key)) && items[item.Key] != null)
|
||||
{
|
||||
FieldsModel model = ControlAttr.ContainsKey(item.Key) ? ControlAttr[item.Key] : new FieldsModel();
|
||||
FieldsModel model = fields.Any(x=>x.__vModel__.Equals(item.Key)) ? fields.Find(x=> x.__vModel__.Equals(item.Key)) : (fields.Any(x => x.__vModel__.Equals(item.Key.Replace("_name", string.Empty))) ? fields.Find(x => x.__vModel__.Equals(item.Key.Replace("_name", string.Empty))) : new FieldsModel());
|
||||
model.separator = ",";
|
||||
var jnpfKey = vModels.FirstOrDefault(x => x.Key.Equals(item.Key)).Value;
|
||||
switch (jnpfKey)
|
||||
{
|
||||
case JnpfKeyConst.USERSSELECT:
|
||||
{
|
||||
if (item.Value != null)
|
||||
var itemValue = item.Value;
|
||||
if (itemValue == null && items.ContainsKey(item.Key.Replace("_name", string.Empty))) itemValue = items[item.Key.Replace("_name", string.Empty)];
|
||||
if (itemValue != null)
|
||||
{
|
||||
var vList = new List<string>();
|
||||
if (item.Value.ToString().Contains("[")) vList = item.Value.ToString().ToObject<List<string>>();
|
||||
else vList.Add(item.Value.ToString());
|
||||
if (itemValue.ToString().Contains("[")) vList = itemValue.ToString().ToObject<List<string>>();
|
||||
else vList.Add(itemValue.ToString());
|
||||
var itemValues = new List<string>();
|
||||
vList.ForEach(it =>
|
||||
{
|
||||
@@ -140,7 +138,6 @@ public class ControlParsing : ITransient
|
||||
}
|
||||
|
||||
break;
|
||||
case JnpfKeyConst.POPUPTABLESELECT:
|
||||
case JnpfKeyConst.POPUPSELECT: // 弹窗选择
|
||||
{
|
||||
if (model.interfaceId.IsNullOrEmpty()) continue;
|
||||
@@ -193,62 +190,45 @@ public class ControlParsing : ITransient
|
||||
{
|
||||
case 1: // SQL数据
|
||||
{
|
||||
var specificData = popupselectDataList.Where(it => it.ContainsKey(model.propsValue) && it.ContainsValue(items[item.Key].ToString())).FirstOrDefault();
|
||||
var specificData = popupselectDataList.Where(it => it.ContainsKey(model.propsValue) && it.ContainsValue(items[item.Key] == null ? model.interfaceId : items[item.Key].ToString())).FirstOrDefault();
|
||||
if (specificData != null)
|
||||
{
|
||||
// 要用模板的 “显示字段 - relationField”来展示数据
|
||||
items[item.Key + "_id"] = items[item.Key];
|
||||
items[item.Key] = specificData[model.relationField];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (model.multiple)
|
||||
{
|
||||
var nameList = new List<string>();
|
||||
items[item.Key].ToObject<List<string>>().ForEach(strIt =>
|
||||
{
|
||||
var specificData = popupselectDataList.Where(it => it.ContainsKey(model.propsValue) && it.ContainsValue(strIt)).FirstOrDefault();
|
||||
if (specificData != null)
|
||||
{
|
||||
// 要用模板的 “显示字段 - relationField”来展示数据
|
||||
if (model.relationField.IsNotEmptyOrNull())
|
||||
nameList.Add(specificData[model.relationField]);
|
||||
}
|
||||
});
|
||||
if (nameList.Any())
|
||||
{
|
||||
items[item.Key + "_id"] = items[item.Key];
|
||||
items[item.Key] = string.Join(model.separator, nameList);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
items[item.Key] = items[item.Key].ToString().Contains("[") ? string.Join(model.separator, items[item.Key].ToObject<List<object>>()) : items[item.Key];
|
||||
}
|
||||
|
||||
// 弹窗选择属性
|
||||
if (model.relational.IsNotEmptyOrNull())
|
||||
foreach (var fItem in model.relational.Split(",")) items[model.__vModel__ + "_" + fItem] = specificData[fItem];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2: // 静态数据
|
||||
{
|
||||
List<string> dataList = items[item.Key].ToJsonString().ToObject<List<string>>();
|
||||
List<string> cascaderList = new List<string>();
|
||||
foreach (var it in dataList)
|
||||
var vara = popupselectDataList.Where(a => a.ContainsValue(items[item.Key] == null ? model.interfaceId : items[item.Key].ToString())).FirstOrDefault();
|
||||
if (vara != null)
|
||||
{
|
||||
var vara = popupselectDataList.Where(a => a.ContainsValue(it)).FirstOrDefault();
|
||||
if (vara != null) cascaderList.Add(vara[model.props.props.label]);
|
||||
}
|
||||
items[item.Key + "_id"] = items[item.Key];
|
||||
items[item.Key] = vara[items[item.Key].ToString()];
|
||||
|
||||
items[item.Key + "_id"] = items[item.Key];
|
||||
items[item.Key] = string.Join(model.separator, cascaderList);
|
||||
// 弹窗选择属性
|
||||
if (model.relational.IsNotEmptyOrNull())
|
||||
foreach (var fItem in model.relational.Split(",")) items[model.__vModel__ + "_" + fItem] = vara[fItem];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3: // Api数据
|
||||
{
|
||||
List<object> cascaderList = new List<object>();
|
||||
if (popupselectDataList != null) popupselectDataList.ForEach(obj => { if (obj[model.propsValue] == items[item.Key].ToString()) cascaderList.Add(obj[model.relationField]); });
|
||||
var vara = popupselectDataList.Where(a => a.ContainsValue(items[item.Key] == null ? model.interfaceId : items[item.Key].ToString())).FirstOrDefault();
|
||||
if (vara != null)
|
||||
{
|
||||
items[item.Key + "_id"] = items[item.Key];
|
||||
items[item.Key] = vara[items[item.Key].ToString()];
|
||||
|
||||
items[item.Key + "_id"] = items[item.Key];
|
||||
items[item.Key] = string.Join(model.separator, cascaderList);
|
||||
// 弹窗选择属性
|
||||
if (model.relational.IsNotEmptyOrNull())
|
||||
foreach (var fItem in model.relational.Split(",")) items[model.__vModel__ + "_" + fItem] = vara[fItem];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -293,6 +273,10 @@ public class ControlParsing : ITransient
|
||||
{
|
||||
items[item.Key + "_id"] = relationFormRealData["id"];
|
||||
items[item.Key] = relationFormRealData.ContainsKey(model.relationField) ? relationFormRealData[model.relationField] : string.Empty;
|
||||
|
||||
// 关联表单属性
|
||||
if (model.relational.IsNotEmptyOrNull())
|
||||
foreach (var fItem in model.relational.Split(",")) items[model.__vModel__ + "_" + fItem] = relationFormRealData[fItem];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -309,11 +293,15 @@ public class ControlParsing : ITransient
|
||||
{
|
||||
var ctList = item.Value.ToObject<List<Dictionary<string, object>>>();
|
||||
var ctVModels = new Dictionary<string, object>();
|
||||
vModels.Where(x => x.Key.Contains(item.Key)).ToList().ForEach(ctItem => ctVModels.Add(ctItem.Key.Split("-").LastOrDefault(), ctItem.Value));
|
||||
if (ctList.Any()) items[item.Key] = await GetParsDataByList(ctList, ctVModels, tenantId);
|
||||
foreach (var ctItem in vModels.Where(x => x.Key.Contains(item.Key)).ToList())
|
||||
{
|
||||
ctVModels.Add(ctItem.Key.Split("-").LastOrDefault(), ctItem.Value);
|
||||
var ctFields = fields.Find(x => x.__vModel__.Equals(ctItem.Key.Split("-").FirstOrDefault())).__config__.children;
|
||||
if (ctList.Any()) items[item.Key] = await GetParsDataByList(ctFields, ctList, ctVModels, tenantId);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return oldDatas;
|
||||
}
|
||||
@@ -493,5 +481,4 @@ public class ControlParsing : ITransient
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -21,9 +21,9 @@ using JNPF.Systems.Entitys.Model.DataInterFace;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Engine;
|
||||
using JNPF.VisualDev.Engine.Core;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using JNPF.WorkFlow.Interfaces.Service;
|
||||
using Mapster;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -50,7 +50,7 @@ public class ExportImportDataHelper : ITransient
|
||||
/// <summary>
|
||||
/// 在线开发运行服务.
|
||||
/// </summary>
|
||||
private readonly IRunService _runService;
|
||||
private readonly RunService _runService;
|
||||
|
||||
/// <summary>
|
||||
/// 单据.
|
||||
@@ -93,7 +93,7 @@ public class ExportImportDataHelper : ITransient
|
||||
public ExportImportDataHelper(
|
||||
ISqlSugarRepository<OrganizeEntity> repositoryRepository,
|
||||
IUserManager userManager,
|
||||
IRunService runService,
|
||||
RunService runService,
|
||||
IBillRullService billRuleService,
|
||||
IDataInterfaceService dataInterfaceService,
|
||||
IDataBaseManager databaseService,
|
||||
@@ -369,6 +369,55 @@ public class ExportImportDataHelper : ITransient
|
||||
field.ableRoleIds = (att as CodeGenUploadAttribute).ableRoleIds;
|
||||
field.ableGroupIds = (att as CodeGenUploadAttribute).ableGroupIds;
|
||||
field.ableIds = (att as CodeGenUploadAttribute).ableIds;
|
||||
field.relational = (att as CodeGenUploadAttribute).showField;
|
||||
configModel = (att as CodeGenUploadAttribute).__config__.Adapt<ConfigModel>();
|
||||
configModel.label = string.Format("{0}({1})", configModel.label, field.__vModel__);
|
||||
field.__config__ = configModel;
|
||||
fieldList.Add(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
return fieldList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据转换模板解析.
|
||||
/// </summary>
|
||||
public static List<FieldsModel> GetDataConversionTemplateParsing<T>(T entity)
|
||||
{
|
||||
List<FieldsModel> fieldList = new List<FieldsModel>();
|
||||
foreach (PropertyInfo prop in entity.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public))
|
||||
{
|
||||
FieldsModel field = new FieldsModel();
|
||||
foreach (var att in prop.GetCustomAttributes(false))
|
||||
{
|
||||
if (att is CodeGenUploadAttribute)
|
||||
{
|
||||
var configModel = new ConfigModel();
|
||||
field.__vModel__ = (att as CodeGenUploadAttribute).__vModel__ ?? (att as CodeGenUploadAttribute).__Model__;
|
||||
field.level = (att as CodeGenUploadAttribute).level;
|
||||
field.min = (att as CodeGenUploadAttribute).min == 0 ? null : (att as CodeGenUploadAttribute).min;
|
||||
field.max = (att as CodeGenUploadAttribute).max == 0 ? null : (att as CodeGenUploadAttribute).max;
|
||||
field.activeTxt = (att as CodeGenUploadAttribute).activeTxt;
|
||||
field.inactiveTxt = (att as CodeGenUploadAttribute).inactiveTxt;
|
||||
field.format = (att as CodeGenUploadAttribute).format;
|
||||
field.multiple = (att as CodeGenUploadAttribute).multiple;
|
||||
field.separator = (att as CodeGenUploadAttribute).separator;
|
||||
field.__slot__ = (att as CodeGenUploadAttribute).__slot__.Adapt<SlotModel>();
|
||||
field.props = (att as CodeGenUploadAttribute).props.Adapt<PropsModel>();
|
||||
field.options = (att as CodeGenUploadAttribute).options;
|
||||
field.propsValue = (att as CodeGenUploadAttribute).propsValue;
|
||||
field.relationField = (att as CodeGenUploadAttribute).relationField;
|
||||
field.modelId = (att as CodeGenUploadAttribute).modelId;
|
||||
field.interfaceId = (att as CodeGenUploadAttribute).interfaceId;
|
||||
field.selectType = (att as CodeGenUploadAttribute).selectType;
|
||||
field.ableDepIds = (att as CodeGenUploadAttribute).ableDepIds;
|
||||
field.ablePosIds = (att as CodeGenUploadAttribute).ablePosIds;
|
||||
field.ableUserIds = (att as CodeGenUploadAttribute).ableUserIds;
|
||||
field.ableRoleIds = (att as CodeGenUploadAttribute).ableRoleIds;
|
||||
field.ableGroupIds = (att as CodeGenUploadAttribute).ableGroupIds;
|
||||
field.ableIds = (att as CodeGenUploadAttribute).ableIds;
|
||||
field.relational = (att as CodeGenUploadAttribute).showField;
|
||||
configModel = (att as CodeGenUploadAttribute).__config__.Adapt<ConfigModel>();
|
||||
configModel.label = string.Format("{0}({1})", configModel.label, field.__vModel__);
|
||||
field.__config__ = configModel;
|
||||
@@ -416,6 +465,56 @@ public class ExportImportDataHelper : ITransient
|
||||
field.ableRoleIds = (att as CodeGenUploadAttribute).ableRoleIds;
|
||||
field.ableGroupIds = (att as CodeGenUploadAttribute).ableGroupIds;
|
||||
field.ableIds = (att as CodeGenUploadAttribute).ableIds;
|
||||
field.relational = (att as CodeGenUploadAttribute).showField;
|
||||
configModel = (att as CodeGenUploadAttribute).__config__.Adapt<ConfigModel>();
|
||||
configModel.label = string.Format("{0}({1})", configModel.label, field.__vModel__);
|
||||
field.__config__ = configModel;
|
||||
fieldList.Add(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fieldList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据转换模板解析.
|
||||
/// </summary>
|
||||
public static List<FieldsModel> GetDataConversionTemplateParsing<T>(T entity, string tableName)
|
||||
{
|
||||
List<FieldsModel> fieldList = new List<FieldsModel>();
|
||||
foreach (PropertyInfo prop in entity.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public))
|
||||
{
|
||||
FieldsModel field = new FieldsModel();
|
||||
foreach (var att in prop.GetCustomAttributes(false))
|
||||
{
|
||||
if (att is CodeGenUploadAttribute)
|
||||
{
|
||||
var configModel = new ConfigModel();
|
||||
field.__vModel__ = string.Format("jnpf_{0}_jnpf_{1}", tableName, (att as CodeGenUploadAttribute).__vModel__ ?? (att as CodeGenUploadAttribute).__Model__);
|
||||
field.level = (att as CodeGenUploadAttribute).level;
|
||||
field.min = (att as CodeGenUploadAttribute).min == 0 ? null : (att as CodeGenUploadAttribute).min;
|
||||
field.max = (att as CodeGenUploadAttribute).max == 0 ? null : (att as CodeGenUploadAttribute).max;
|
||||
field.activeTxt = (att as CodeGenUploadAttribute).activeTxt;
|
||||
field.inactiveTxt = (att as CodeGenUploadAttribute).inactiveTxt;
|
||||
field.format = (att as CodeGenUploadAttribute).format;
|
||||
field.multiple = (att as CodeGenUploadAttribute).multiple;
|
||||
field.separator = (att as CodeGenUploadAttribute).separator;
|
||||
field.__slot__ = (att as CodeGenUploadAttribute).__slot__.Adapt<SlotModel>();
|
||||
field.props = (att as CodeGenUploadAttribute).props.Adapt<PropsModel>();
|
||||
field.options = (att as CodeGenUploadAttribute).options;
|
||||
field.propsValue = (att as CodeGenUploadAttribute).propsValue;
|
||||
field.relationField = (att as CodeGenUploadAttribute).relationField;
|
||||
field.modelId = (att as CodeGenUploadAttribute).modelId;
|
||||
field.interfaceId = (att as CodeGenUploadAttribute).interfaceId;
|
||||
field.selectType = (att as CodeGenUploadAttribute).selectType;
|
||||
field.ableDepIds = (att as CodeGenUploadAttribute).ableDepIds;
|
||||
field.ablePosIds = (att as CodeGenUploadAttribute).ablePosIds;
|
||||
field.ableUserIds = (att as CodeGenUploadAttribute).ableUserIds;
|
||||
field.ableRoleIds = (att as CodeGenUploadAttribute).ableRoleIds;
|
||||
field.ableGroupIds = (att as CodeGenUploadAttribute).ableGroupIds;
|
||||
field.ableIds = (att as CodeGenUploadAttribute).ableIds;
|
||||
field.relational = (att as CodeGenUploadAttribute).showField;
|
||||
configModel = (att as CodeGenUploadAttribute).__config__.Adapt<ConfigModel>();
|
||||
configModel.label = string.Format("{0}({1})", configModel.label, field.__vModel__);
|
||||
field.__config__ = configModel;
|
||||
@@ -660,78 +759,78 @@ public class ExportImportDataHelper : ITransient
|
||||
return new { dataRow = resData, headerRow = headerRow };
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 导入数据.
|
||||
///// </summary>
|
||||
///// <param name="tInfo">模板信息.</param>
|
||||
///// <param name="list">数据集合.</param>
|
||||
///// <returns>[成功列表,失败列表].</returns>
|
||||
//public async Task<object[]> ImportMenuData(TemplateParsingBase tInfo, List<Dictionary<string, object>> list)
|
||||
//{
|
||||
// List<Dictionary<string, object>> userInputList = ImportFirstVerify(tInfo, list);
|
||||
// List<FieldsModel> fieldsModelList = tInfo.AllFieldsModel.Where(x => tInfo.selectKey.Contains(x.__vModel__)).ToList();
|
||||
/// <summary>
|
||||
/// 导入数据.
|
||||
/// </summary>
|
||||
/// <param name="tInfo">模板信息.</param>
|
||||
/// <param name="list">数据集合.</param>
|
||||
/// <returns>[成功列表,失败列表].</returns>
|
||||
public async Task<object[]> ImportMenuData(TemplateParsingBase tInfo, List<Dictionary<string, object>> list)
|
||||
{
|
||||
List<Dictionary<string, object>> userInputList = ImportFirstVerify(tInfo, list);
|
||||
List<FieldsModel> fieldsModelList = tInfo.AllFieldsModel.Where(x => tInfo.selectKey.Contains(x.__vModel__)).ToList();
|
||||
|
||||
// var successList = new List<Dictionary<string, object>>();
|
||||
// var errorsList = new List<Dictionary<string, object>>();
|
||||
var successList = new List<Dictionary<string, object>>();
|
||||
var errorsList = new List<Dictionary<string, object>>();
|
||||
|
||||
// // 捞取控件解析数据
|
||||
// var cData = await GetCDataList(tInfo.AllFieldsModel, new Dictionary<string, List<Dictionary<string, string>>>());
|
||||
// var res = await ImportDataAssemble(fieldsModelList, userInputList, cData);
|
||||
// res.Where(x => x.ContainsKey("errorsInfo")).ToList().ForEach(item => errorsList.Add(item));
|
||||
// res.Where(x => !x.ContainsKey("errorsInfo")).ToList().ForEach(item => successList.Add(item));
|
||||
// 捞取控件解析数据
|
||||
var cData = await GetCDataList(tInfo.AllFieldsModel, new Dictionary<string, List<Dictionary<string, string>>>());
|
||||
var res = await ImportDataAssemble(fieldsModelList, userInputList, cData);
|
||||
res.Where(x => x.ContainsKey("errorsInfo")).ToList().ForEach(item => errorsList.Add(item));
|
||||
res.Where(x => !x.ContainsKey("errorsInfo")).ToList().ForEach(item => successList.Add(item));
|
||||
|
||||
// try
|
||||
// {
|
||||
// // 唯一验证已处理,入库前去掉.
|
||||
// tInfo.AllFieldsModel.Where(x => x.__config__.jnpfKey.Equals(JnpfKeyConst.COMINPUT) && x.__config__.unique).ToList().ForEach(item => item.__config__.unique = false);
|
||||
// _sqlSugarClient.BeginTran();
|
||||
// foreach (var item in successList)
|
||||
// {
|
||||
// if (item.ContainsKey("Update_MainTablePrimary_Id"))
|
||||
// {
|
||||
// string? mainId = item["Update_MainTablePrimary_Id"].ToString();
|
||||
// var haveTableSql = await _runService.GetUpdateSqlByTemplate(tInfo, new VisualDevModelDataUpInput() { data = item.ToJsonString() }, mainId);
|
||||
// foreach (var it in haveTableSql) await _databaseService.ExecuteSql(tInfo.DbLink, it); // 修改功能数据
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if ((tInfo.visualDevEntity?.EnableFlow.Equals(1)).ParseToBool())
|
||||
// {
|
||||
// var flowId = _repository.AsSugarClient().Queryable<WorkFlow.Entitys.Entity.FlowFormEntity>().First(x => x.Id.Equals(tInfo.visualDevEntity.Id)).FlowId;
|
||||
// await _flowTaskService.Create(new Common.Models.WorkFlow.FlowTaskSubmitModel() { formData = item.ToJsonString(), flowId = flowId, flowUrgent = 1 });
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// string? mainId = YitIdHelper.NextId().ToString();
|
||||
// var haveTableSql = await _runService.GetCreateSqlByTemplate(tInfo, new VisualDevModelDataCrInput() { data = item.ToJsonString() }, mainId);
|
||||
try
|
||||
{
|
||||
// 唯一验证已处理,入库前去掉.
|
||||
tInfo.AllFieldsModel.Where(x => x.__config__.jnpfKey.Equals(JnpfKeyConst.COMINPUT) && x.__config__.unique).ToList().ForEach(item => item.__config__.unique = false);
|
||||
_sqlSugarClient.BeginTran();
|
||||
foreach (var item in successList)
|
||||
{
|
||||
if (item.ContainsKey("Update_MainTablePrimary_Id"))
|
||||
{
|
||||
string? mainId = item["Update_MainTablePrimary_Id"].ToString();
|
||||
var haveTableSql = await _runService.GetUpdateSqlByTemplate(tInfo, new VisualDevModelDataUpInput() { data = item.ToJsonString() }, mainId);
|
||||
foreach (var it in haveTableSql) await _databaseService.ExecuteSql(tInfo.DbLink, it); // 修改功能数据
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((tInfo.visualDevEntity?.EnableFlow.Equals(1)).ParseToBool())
|
||||
{
|
||||
var flowId = _repository.AsSugarClient().Queryable<WorkFlow.Entitys.Entity.FlowFormEntity>().First(x => x.Id.Equals(tInfo.visualDevEntity.Id)).FlowId;
|
||||
await _flowTaskService.Create(new Common.Models.WorkFlow.FlowTaskSubmitModel() { formData = item, flowId = flowId, flowUrgent = 1, status = 1 });
|
||||
}
|
||||
else
|
||||
{
|
||||
string? mainId = YitIdHelper.NextId().ToString();
|
||||
var haveTableSql = await _runService.GetCreateSqlByTemplate(tInfo, new VisualDevModelDataCrInput() { data = item.ToJsonString() }, mainId);
|
||||
|
||||
// // 主表自增长Id.
|
||||
// if (haveTableSql.ContainsKey("MainTableReturnIdentity"))
|
||||
// {
|
||||
// mainId = haveTableSql["MainTableReturnIdentity"].First().First().Value.ToString();
|
||||
// haveTableSql.Remove("MainTableReturnIdentity");
|
||||
// }
|
||||
// foreach (var it in haveTableSql)
|
||||
// await _databaseService.ExecuteSql(tInfo.DbLink, it.Key, it.Value); // 新增功能数据
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// 主表自增长Id.
|
||||
if (haveTableSql.ContainsKey("MainTableReturnIdentity"))
|
||||
{
|
||||
mainId = haveTableSql["MainTableReturnIdentity"].First().First().Value.ToString();
|
||||
haveTableSql.Remove("MainTableReturnIdentity");
|
||||
}
|
||||
foreach (var it in haveTableSql)
|
||||
await _databaseService.ExecuteSql(tInfo.DbLink, it.Key, it.Value); // 新增功能数据
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// _sqlSugarClient.CommitTran();
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// _sqlSugarClient.RollbackTran();
|
||||
// throw;
|
||||
// }
|
||||
_sqlSugarClient.CommitTran();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_sqlSugarClient.RollbackTran();
|
||||
throw;
|
||||
}
|
||||
|
||||
// errorsList.ForEach(item =>
|
||||
// {
|
||||
// if (item.ContainsKey("errorsInfo") && item["errorsInfo"].IsNotEmptyOrNull()) item["errorsInfo"] = item["errorsInfo"].ToString().TrimStart(',').TrimEnd(',');
|
||||
// });
|
||||
errorsList.ForEach(item =>
|
||||
{
|
||||
if (item.ContainsKey("errorsInfo") && item["errorsInfo"].IsNotEmptyOrNull()) item["errorsInfo"] = item["errorsInfo"].ToString().TrimStart(',').TrimEnd(',');
|
||||
});
|
||||
|
||||
// return new object[] { successList, errorsList };
|
||||
//}
|
||||
return new object[] { successList, errorsList };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Excel 转输出 Model.
|
||||
|
||||
Reference in New Issue
Block a user