This commit is contained in:
DEVICE8\12494
2023-03-30 16:22:04 +08:00

View File

@@ -63,7 +63,8 @@ public class FormDataParsing : ITransient
/// <summary>
/// 服务基础仓储.
/// </summary>
private readonly ISqlSugarRepository<VisualDevEntity> _db;
//private readonly ISqlSugarRepository<VisualDevEntity> _db;
private readonly ISqlSugarClient _sugar;
/// <summary>
/// 构造.
@@ -85,7 +86,8 @@ public class FormDataParsing : ITransient
_cacheManager = cacheManager;
_databaseService = databaseService;
_dataInterfaceService = dataInterfaceService;
_db = context;
_sugar = context.AsSugarClient().CopyNew();
//_db = context;
_memCache = memCache;
}
#endregion
@@ -629,7 +631,7 @@ public class FormDataParsing : ITransient
case JnpfKeyConst.POSSELECT: // 岗位
if (!GetCacheValues(fieldCacheKey, templateData))
{
List<PositionEntity>? positionEntityList = await _db.AsSugarClient().Queryable<PositionEntity>().Where(u => u.DeleteMark == null).ToListAsync();
List<PositionEntity>? positionEntityList = await _sugar.Queryable<PositionEntity>().Where(u => u.DeleteMark == null).ToListAsync();
List<Dictionary<string, string>> positionList = new List<Dictionary<string, string>>();
foreach (PositionEntity? item in positionEntityList)
{
@@ -646,7 +648,7 @@ public class FormDataParsing : ITransient
case JnpfKeyConst.GROUPSELECT: // 分组
if (!GetCacheValues(fieldCacheKey, templateData))
{
List<GroupEntity>? positionEntityList = await _db.AsSugarClient().Queryable<GroupEntity>().Where(u => u.DeleteMark == null).ToListAsync();
List<GroupEntity>? positionEntityList = await _sugar.Queryable<GroupEntity>().Where(u => u.DeleteMark == null).ToListAsync();
List<Dictionary<string, string>> positionList = new List<Dictionary<string, string>>();
foreach (GroupEntity? item in positionEntityList)
{
@@ -663,7 +665,7 @@ public class FormDataParsing : ITransient
case JnpfKeyConst.ROLESELECT: // 角色
if (!GetCacheValues(fieldCacheKey, templateData))
{
List<RoleEntity>? positionEntityList = await _db.AsSugarClient().Queryable<RoleEntity>().Where(u => u.DeleteMark == null).ToListAsync();
List<RoleEntity>? positionEntityList = await _sugar.Queryable<RoleEntity>().Where(u => u.DeleteMark == null).ToListAsync();
List<Dictionary<string, string>> positionList = new List<Dictionary<string, string>>();
foreach (RoleEntity? item in positionEntityList)
{
@@ -697,7 +699,7 @@ public class FormDataParsing : ITransient
}
else
{
List<ProvinceEntity>? addressEntityList = await _db.AsSugarClient().Queryable<ProvinceEntity>().Select(x => new ProvinceEntity { Id = x.Id, ParentId = x.ParentId, Type = x.Type, FullName = x.FullName }).ToListAsync();
List<ProvinceEntity>? addressEntityList = await _sugar.Queryable<ProvinceEntity>().Select(x => new ProvinceEntity { Id = x.Id, ParentId = x.ParentId, Type = x.Type, FullName = x.FullName }).ToListAsync();
// 处理省市区树
addressEntityList.Where(x => x.Type == "1").ToList().ForEach(item => item.QuickQuery = item.FullName);
@@ -739,7 +741,7 @@ public class FormDataParsing : ITransient
}
else
{
List<ProvinceEntity>? addressEntityList = await _db.AsSugarClient().Queryable<ProvinceEntity>().Select(x => new ProvinceEntity { Id = x.Id, ParentId = x.ParentId, Type = x.Type, FullName = x.FullName }).ToListAsync();
List<ProvinceEntity>? addressEntityList = await _sugar.Queryable<ProvinceEntity>().Select(x => new ProvinceEntity { Id = x.Id, ParentId = x.ParentId, Type = x.Type, FullName = x.FullName }).ToListAsync();
// 处理省市区树
addressEntityList.Where(x => x.Type == "1").ToList().ForEach(item => item.QuickQuery = item.FullName);
@@ -795,7 +797,7 @@ public class FormDataParsing : ITransient
}
else
{
List<UserEntity>? userEntityList = await _db.AsSugarClient().Queryable<UserEntity>().Where(x => x.DeleteMark == null).Select(x => new UserEntity() { Id = x.Id, RealName = x.RealName, Account = x.Account }).ToListAsync();
List<UserEntity>? userEntityList = await _sugar.Queryable<UserEntity>().Where(x => x.DeleteMark == null).Select(x => new UserEntity() { Id = x.Id, RealName = x.RealName, Account = x.Account }).ToListAsync();
List<Dictionary<string, string>> userList = new List<Dictionary<string, string>>();
foreach (UserEntity? item in userEntityList)
@@ -821,32 +823,32 @@ public class FormDataParsing : ITransient
else
{
var addList = new List<Dictionary<string, string>>();
(await _db.AsSugarClient().Queryable<UserEntity>().Where(x => x.DeleteMark == null).Select(x => new { x.Id, x.RealName, x.Account }).ToListAsync()).ForEach(item =>
(await _sugar.Queryable<UserEntity>().Where(x => x.DeleteMark == null).Select(x => new { x.Id, x.RealName, x.Account }).ToListAsync()).ForEach(item =>
{
Dictionary<string, string> user = new Dictionary<string, string>();
user.Add(item.Id + "--user", item.RealName + "/" + item.Account);
addList.Add(user);
});
(await _db.AsSugarClient().Queryable<OrganizeEntity>().Where(x => x.DeleteMark == null).Select(x => new { x.Id, x.FullName }).ToListAsync()).ForEach(item =>
(await _sugar.Queryable<OrganizeEntity>().Where(x => x.DeleteMark == null).Select(x => new { x.Id, x.FullName }).ToListAsync()).ForEach(item =>
{
Dictionary<string, string> user = new Dictionary<string, string>();
user.Add(item.Id + "--company", item.FullName);
user.Add(item.Id + "--department", item.FullName);
addList.Add(user);
});
(await _db.AsSugarClient().Queryable<RoleEntity>().Where(x => x.DeleteMark == null).Select(x => new { x.Id, x.FullName }).ToListAsync()).ForEach(item =>
(await _sugar.Queryable<RoleEntity>().Where(x => x.DeleteMark == null).Select(x => new { x.Id, x.FullName }).ToListAsync()).ForEach(item =>
{
Dictionary<string, string> user = new Dictionary<string, string>();
user.Add(item.Id + "--role", item.FullName);
addList.Add(user);
});
(await _db.AsSugarClient().Queryable<PositionEntity>().Where(x => x.DeleteMark == null).Select(x => new { x.Id, x.FullName }).ToListAsync()).ForEach(item =>
(await _sugar.Queryable<PositionEntity>().Where(x => x.DeleteMark == null).Select(x => new { x.Id, x.FullName }).ToListAsync()).ForEach(item =>
{
Dictionary<string, string> user = new Dictionary<string, string>();
user.Add(item.Id + "--position", item.FullName);
addList.Add(user);
});
(await _db.AsSugarClient().Queryable<GroupEntity>().Where(x => x.DeleteMark == null).Select(x => new { x.Id, x.FullName }).ToListAsync()).ForEach(item =>
(await _sugar.Queryable<GroupEntity>().Where(x => x.DeleteMark == null).Select(x => new { x.Id, x.FullName }).ToListAsync()).ForEach(item =>
{
Dictionary<string, string> user = new Dictionary<string, string>();
user.Add(item.Id + "--group", item.FullName);
@@ -892,7 +894,7 @@ public class FormDataParsing : ITransient
{
if (!GetCacheValues(fieldCacheKey, templateData))
{
List<OrganizeEntity>? dep_organizeEntityList = await _db.AsSugarClient().Queryable<OrganizeEntity>().Where(d => d.EnabledMark == 1 && d.DeleteMark == null)
List<OrganizeEntity>? dep_organizeEntityList = await _sugar.Queryable<OrganizeEntity>().Where(d => d.EnabledMark == 1 && d.DeleteMark == null)
.WhereIF(orgType.Equals(JnpfKeyConst.DEPSELECT), d => d.Category.Equals("department")).ToListAsync();
List<Dictionary<string, object>> vlist = new List<Dictionary<string, object>>();
@@ -962,7 +964,7 @@ public class FormDataParsing : ITransient
parameter.Add(new SugarParameter("@currentChargeorganizationAndSuborganization", subsidiary));
}
DbLinkEntity? linkEntity = await _db.AsSugarClient().Queryable<DbLinkEntity>().Where(m => m.Id == dynamic.DBLinkId && m.DeleteMark == null).FirstAsync();
DbLinkEntity? linkEntity = await _sugar.Queryable<DbLinkEntity>().Where(m => m.Id == dynamic.DBLinkId && m.DeleteMark == null).FirstAsync();
if (linkEntity == null) linkEntity = _databaseService.GetTenantDbLink(_userManager.TenantId, _userManager.TenantDbName);
_dataInterfaceService.ReplaceParameterValue(dynamic, new Dictionary<string, string>());
System.Data.DataTable? dt = _databaseService.GetInterFaceData(linkEntity, dynamic.Query, parameter.ToArray());
@@ -1072,7 +1074,7 @@ public class FormDataParsing : ITransient
/// <returns>List.</returns>
private async Task<List<Dictionary<string, string>>> GetDictionaryList(string? dictionaryTypeId = null)
{
List<DictionaryDataEntity> dictionaryDataEntityList = await _db.AsSugarClient().Queryable<DictionaryDataEntity, DictionaryTypeEntity>((a, b) => new JoinQueryInfos(JoinType.Left, b.Id == a.DictionaryTypeId))
List<DictionaryDataEntity> dictionaryDataEntityList = await _sugar.Queryable<DictionaryDataEntity, DictionaryTypeEntity>((a, b) => new JoinQueryInfos(JoinType.Left, b.Id == a.DictionaryTypeId))
.WhereIF(dictionaryTypeId.IsNotEmptyOrNull(), (a, b) => b.Id == dictionaryTypeId || b.EnCode == dictionaryTypeId).Where(a => a.DeleteMark == null).ToListAsync();
List<Dictionary<string, string>> dictionaryDataList = new List<Dictionary<string, string>>();
@@ -1193,10 +1195,10 @@ public class FormDataParsing : ITransient
break;
case JnpfKeyConst.CREATEUSER:
case JnpfKeyConst.MODIFYUSER:
dataMap[key] = await _db.AsSugarClient().Queryable<UserEntity>().Where(x => x.Id == dataValue).Select(x => SqlFunc.MergeString(x.RealName, "/", x.Account)).FirstAsync();
dataMap[key] = await _sugar.Queryable<UserEntity>().Where(x => x.Id == dataValue).Select(x => SqlFunc.MergeString(x.RealName, "/", x.Account)).FirstAsync();
break;
case JnpfKeyConst.CURRPOSITION:
dataMap[key] = (await _db.AsSugarClient().Queryable<PositionEntity>().FirstAsync(p => p.Id == dataMap[key].ToString()))?.FullName;
dataMap[key] = (await _sugar.Queryable<PositionEntity>().FirstAsync(p => p.Id == dataMap[key].ToString()))?.FullName;
if (dataMap[key].IsNullOrEmpty()) dataMap[key] = " ";
break;
case JnpfKeyConst.CURRORGANIZE:
@@ -1429,7 +1431,7 @@ public class FormDataParsing : ITransient
if (webType == 3)
{
var ids = list.Select(x => x[primaryKey]).ToList();
var flowTaskList = await _db.AsSugarClient().Queryable<FlowTaskEntity>().Where(x => ids.Contains(x.Id)).Select(x => new FlowTaskEntity() { Id = x.Id, Status = x.Status }).ToListAsync();
var flowTaskList = await _sugar.Queryable<FlowTaskEntity>().Where(x => ids.Contains(x.Id)).Select(x => new FlowTaskEntity() { Id = x.Id, Status = x.Status }).ToListAsync();
list.ForEach(item =>
{
if (flowTaskList.Any(x => x.Id.Equals(item[primaryKey].ToString())))
@@ -1718,7 +1720,7 @@ public class FormDataParsing : ITransient
dataMap[key] = await _memCache.GetOrCreateAsync($"organizeId_{dataValue}", async entry =>
{
entry.SlidingExpiration = TimeSpan.FromSeconds(60);
return (await _db.AsSugarClient().Queryable<OrganizeEntity>().FirstAsync(x => x.Id == dataValue.ToString()))?.FullName;
return (await _sugar.Queryable<OrganizeEntity>().FirstAsync(x => x.Id == dataValue.ToString()))?.FullName;
});
break;
case JnpfKeyConst.MODIFYUSER:
@@ -1726,7 +1728,7 @@ public class FormDataParsing : ITransient
dataMap[key] = await _memCache.GetOrCreateAsync($"userId_{dataValue}", async entry =>
{
entry.SlidingExpiration = TimeSpan.FromSeconds(60);
return await _db.AsSugarClient().Queryable<UserEntity>().Where(x => x.Id == dataValue.ToString()).Select(x => SqlFunc.MergeString(x.RealName, "/", x.Account)).FirstAsync();
return await _sugar.Queryable<UserEntity>().Where(x => x.Id == dataValue.ToString()).Select(x => SqlFunc.MergeString(x.RealName, "/", x.Account)).FirstAsync();
});
break;
case JnpfKeyConst.MODIFYTIME:
@@ -1737,7 +1739,7 @@ public class FormDataParsing : ITransient
dataMap[key] = await _memCache.GetOrCreateAsync($"positionId_{dataValue}", async entry =>
{
entry.SlidingExpiration = TimeSpan.FromSeconds(60);
return (await _db.AsSugarClient().Queryable<PositionEntity>().FirstAsync(x => x.Id == dataValue.ToString()))?.FullName;
return (await _sugar.Queryable<PositionEntity>().FirstAsync(x => x.Id == dataValue.ToString()))?.FullName;
});
break;
case JnpfKeyConst.POPUPTABLESELECT:
@@ -1891,7 +1893,7 @@ public class FormDataParsing : ITransient
else
{
// 根据可视化功能ID获取该模板全部数据
var relationFormModel = await _db.AsSugarClient().Queryable<VisualDevEntity>().FirstAsync(v => v.Id == model.modelId);
var relationFormModel = await _sugar.Queryable<VisualDevEntity>().FirstAsync(v => v.Id == model.modelId);
var newFieLdsModelList = relationFormModel.FormData.ToObject<FormDataModel>().fields.FindAll(x => model.relationField.Equals(x.__vModel__));
VisualDevModelListQueryInput listQueryInput = new VisualDevModelListQueryInput
{