This commit is contained in:
2023-05-31 10:19:05 +08:00
parent 1b65a7a9e5
commit 9c621c75cd
238 changed files with 9905 additions and 4034 deletions

View File

@@ -1,5 +1,4 @@
using System.Data;
using JNPF.Common.Configuration;
using JNPF.Common.Configuration;
using JNPF.Common.Const;
using JNPF.Common.Core.Manager;
using JNPF.Common.Core.Manager.Files;
@@ -16,6 +15,7 @@ using JNPF.DataEncryption;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.FriendlyException;
using JNPF.Logging.Attributes;
using JNPF.RemoteRequest.Extensions;
using JNPF.Systems.Entitys.Model.DataInterFace;
using JNPF.Systems.Entitys.Permission;
@@ -23,19 +23,18 @@ using JNPF.Systems.Entitys.System;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev.Engine;
using JNPF.VisualDev.Engine.Core;
using JNPF.VisualDev.Engine.Security;
using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Entitys.Dto.VisualDev;
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
using JNPF.VisualDev.Interfaces;
using JNPF.WorkFlow.Entitys.Entity;
using JNPF.WorkFlow.Interfaces.Service;
using Mapster;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using SqlSugar;
using Tnb.ProductionMgr.Interfaces;
using Yitter.IdGenerator;
namespace JNPF.VisualDev
{
@@ -106,7 +105,6 @@ namespace JNPF.VisualDev
/// </summary>
private readonly ITenant _db;
/// <summary>
/// 初始化一个<see cref="VisualDevModelDataService"/>类型的新实例.
/// </summary>
@@ -158,7 +156,7 @@ namespace JNPF.VisualDev
if (data.EnableFlow.Equals(1) && data.FlowId.IsNullOrWhiteSpace()) return new { code = 400, msg = "该流程功能未绑定流程!" };
if (data.WebType.Equals(1) && data.FormData.IsNullOrWhiteSpace()) return new { code = 400, msg = "该模板内表单内容为空,无法预览!" };
else if (data.WebType.Equals(2) && data.ColumnData.IsNullOrWhiteSpace()) return new { code = 400, msg = "该模板内列表内容为空,无法预览!" };
return new { code = 200, data = data.Adapt<VisualDevModelDataConfigOutput>() };
return new { code = 200, data = GetVisualDevModelDataConfig(data) };
}
/// <summary>
@@ -206,21 +204,21 @@ namespace JNPF.VisualDev
[HttpGet("{modelId}/{id}")]
public async Task<dynamic> GetInfo(string id, string modelId)
{
// modified by PhilPan 2023-04-12 重写接口
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
if (overideSvc != null && overideSvc.OverideFuncs.GetAsync != null)
{
return await overideSvc.OverideFuncs.GetAsync(id);
}
else
{
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true); // 模板实体
// 有表
if (!string.IsNullOrEmpty(templateEntity.Tables) && !"[]".Equals(templateEntity.Tables))
//modified by pf 2023-04-12 返回值不序列化成字符串
return new { id = id, data = (await _runService.GetHaveTableInfo(id, templateEntity)) };
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true); // 模板实体
// 有表
if (!string.IsNullOrEmpty(templateEntity.Tables) && !"[]".Equals(templateEntity.Tables))
// modified by PhilPan 2023-04-12 返回值不序列化成字符串
return new { id = id, data = (await _runService.GetHaveTableInfo(id, templateEntity)) };
else
return null;
}
}
/// <summary>
@@ -232,21 +230,20 @@ namespace JNPF.VisualDev
[HttpGet("{modelId}/{id}/DataChange")]
public async Task<dynamic> GetDetails(string id, string modelId)
{
//modified by PhilPan 2023-04-12 重写接口
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
if (overideSvc != null && overideSvc.OverideFuncs.GetDetailsAsync != null)
{
return await overideSvc.OverideFuncs.GetDetailsAsync(id);
}
else
{
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true); // 模板实体
// 有表
if (!string.IsNullOrEmpty(templateEntity.Tables) && !"[]".Equals(templateEntity.Tables))
//modified by pf 2023-04-12 返回值不序列化成字符串
return new { id = id, data = await _runService.GetHaveTableInfoDetails(id, templateEntity) };
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true); // 模板实体
// 有表
if (!string.IsNullOrEmpty(templateEntity.Tables) && !"[]".Equals(templateEntity.Tables))
return new { id = id, data = await _runService.GetHaveTableInfoDetails(id, templateEntity) };
else
return null;
}
}
#endregion
@@ -309,16 +306,31 @@ namespace JNPF.VisualDev
[HttpPost("{modelId}/List")]
public async Task<dynamic> List(string modelId, [FromBody] VisualDevModelListQueryInput input)
{
//modified by PhilPan 2023-04-12 重写接口
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
if (overideSvc != null && overideSvc.OverideFuncs.GetListAsync != null)
{
return await overideSvc.OverideFuncs.GetListAsync(input);
}
else
{
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true);
return await _runService.GetListResult(templateEntity, input);
}
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true);
return await _runService.GetListResult(templateEntity, input);
}
/// <summary>
/// 外链获取数据列表.
/// </summary>
/// <param name="modelId">主键id.</param>
/// <param name="input">分页查询条件.</param>
/// <returns></returns>
[HttpPost("{modelId}/ListLink")]
[AllowAnonymous]
[IgnoreLog]
public async Task<dynamic> ListLink(string modelId, [FromBody] VisualDevModelListQueryInput input)
{
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true);
if (templateEntity == null) throw Oops.Oh(ErrorCode.D1420);
return await _runService.GetListResult(templateEntity, input);
}
/// <summary>
@@ -330,6 +342,7 @@ namespace JNPF.VisualDev
[HttpPost("{modelId}")]
public async Task Create(string modelId, [FromBody] VisualDevModelDataCrInput visualdevModelDataCrForm)
{
//modified by PhilPan 2023-04-12 重写接口
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
if (overideSvc != null && overideSvc.OverideFuncs.CreateAsync != null)
{
@@ -352,6 +365,7 @@ namespace JNPF.VisualDev
[HttpPut("{modelId}/{id}")]
public async Task Update(string modelId, string id, [FromBody] VisualDevModelDataUpInput visualdevModelDataUpForm)
{
//modified by PhilPan 2023-04-12 重写接口
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
if (overideSvc != null && overideSvc.OverideFuncs.UpdateAsync != null)
{
@@ -373,6 +387,7 @@ namespace JNPF.VisualDev
[HttpDelete("{modelId}/{id}")]
public async Task Delete(string id, string modelId)
{
//modified by PhilPan 2023-04-12 重写接口
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
if (overideSvc != null && overideSvc.OverideFuncs.DeleteAsync != null)
{
@@ -394,6 +409,7 @@ namespace JNPF.VisualDev
[HttpPost("batchDelete/{modelId}")]
public async Task BatchDelete(string modelId, [FromBody] VisualDevModelDataBatchDelInput input)
{
//modified by PhilPan 2023-04-12 重写接口
var overideSvc = OverideVisualDevManager.GetOrDefault(modelId);
if (overideSvc != null && overideSvc.OverideFuncs.DeleteRangeAsync != null)
{
@@ -416,7 +432,6 @@ namespace JNPF.VisualDev
public async Task<dynamic> Export(string modelId, [FromBody] VisualDevModelListQueryInput input)
{
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(modelId, true);
List<VisualDevModelDataEntity> list = new List<VisualDevModelDataEntity>();
if (input.dataType == "1") input.pageSize = 99999999;
PageResult<Dictionary<string, object>>? pageList = await _runService.GetListResult(templateEntity, input);
@@ -439,6 +454,16 @@ namespace JNPF.VisualDev
var firstColumns = res.First().ToObject<Dictionary<string, int>>();
var resultList = res.Last().ToObject<List<Dictionary<string, object>>>();
var newResultList = new List<Dictionary<string, object>>();
// 行内编辑
if (templateInfo.ColumnData.type.Equals(4))
{
resultList.ForEach(row =>
{
foreach (var data in row) if (data.Key.Contains("_name") && row.ContainsKey(data.Key.Replace("_name", string.Empty))) row[data.Key.Replace("_name", string.Empty)] = data.Value;
});
}
resultList.ForEach(row =>
{
foreach (var item in input.selectKey)
@@ -451,7 +476,7 @@ namespace JNPF.VisualDev
}
});
var excelName = string.Format("{0}", SnowflakeIdHelper.NextId());
var excelName = string.Format("表单信息{0}", DateTime.Now.ToString("yyyyMMddHHmmssf"));
_cacheManager.Set(excelName + ".xls", string.Empty);
return firstColumns.Any() ? await ExcelCreateModel(templateInfo.AllFieldsModel, resultList, input.selectKey, excelName, firstColumns)
: await ExcelCreateModel(templateInfo.AllFieldsModel, resultList, input.selectKey, excelName);
@@ -724,7 +749,7 @@ namespace JNPF.VisualDev
resData.ForEach(items =>
{
foreach (var item in items)
foreach(var item in items)
{
var vmodel = tInfo.AllFieldsModel.FirstOrDefault(x => x.__vModel__.Equals(item.Key));
if (vmodel != null && vmodel.__config__.jnpfKey.Equals(JnpfKeyConst.DATE) && item.Value.IsNotEmptyOrNull()) items[item.Key] = item.Value + " ";
@@ -872,7 +897,7 @@ namespace JNPF.VisualDev
var len = rowChildDatas.Select(x => x.Value.Count()).OrderByDescending(x => x).FirstOrDefault();
if (len > 0)
if (len != null && len > 0)
{
for (int i = 0; i < len; i++)
{
@@ -1020,7 +1045,8 @@ namespace JNPF.VisualDev
if (tInfo.visualDevEntity.EnableFlow.Equals(1))
{
var flowId = _visualDevRepository.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 });
var id = (await _visualDevRepository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().Where(x => x.TemplateId == flowId && x.EnabledMark == 1 && x.DeleteMark == null).Select(x => x.Id).FirstAsync());
await _flowTaskService.Create(new Common.Models.WorkFlow.FlowTaskSubmitModel() { formData = item, flowId = id, flowUrgent = 1, status = 1 });
}
else
{
@@ -1178,7 +1204,7 @@ namespace JNPF.VisualDev
for (var i = 1; i < vlist.Count; i++)
{
var errorTxt = tInfo.AllFieldsModel.Find(x => x.__vModel__.Equals(uniqueKey)).__config__.label + ": 值不能重复";
if (!ctItemErrors.Any(x => x.Equals(errorTxt))) ctItemErrors.Add(errorTxt);
if (!ctItemErrors.Any(x=>x.Equals(errorTxt))) ctItemErrors.Add(errorTxt);
}
}
}
@@ -1498,7 +1524,7 @@ namespace JNPF.VisualDev
foreach (var it in dictionaryDataList)
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
if (propsValue.Equals("id")) dictionary.Add(it.Id, it.FullName);
if(propsValue.Equals("id")) dictionary.Add(it.Id, it.FullName);
if (propsValue.Equals("enCode")) dictionary.Add(it.EnCode, it.FullName);
addItem.Add(dictionary);
}
@@ -1709,7 +1735,7 @@ namespace JNPF.VisualDev
Dictionary<string, string> dic = new Dictionary<string, string>();
dic[data.Value<string>(propsValue)] = data.Value<string>(propsLabel);
list.Add(dic);
if (children != null && data.Value<object>(children) != null && data.Value<object>(children).ToString().IsNotEmptyOrNull())
if (children!=null && data.Value<object>(children) != null && data.Value<object>(children).ToString().IsNotEmptyOrNull())
list.AddRange(GetDynamicInfiniteData(data.Value<object>(children).ToString(), item.props.props));
}
}
@@ -2635,7 +2661,7 @@ namespace JNPF.VisualDev
}
}
if (newDataItems.ContainsKey(errorKey))
if(newDataItems.ContainsKey(errorKey))
{
if (dataItems.ContainsKey(errorKey)) dataItems[errorKey] = newDataItems[errorKey].ToString();
else dataItems.Add(errorKey, newDataItems[errorKey]);
@@ -2920,6 +2946,52 @@ namespace JNPF.VisualDev
return pEntity.Id;
}
}
/// <summary>
/// 处理模板默认值.
/// 用户选择 , 部门选择.
/// </summary>
/// <param name="config">模板.</param>
/// <returns></returns>
private VisualDevModelDataConfigOutput GetVisualDevModelDataConfig(VisualDevEntity config)
{
if(config.WebType.Equals(4)) return config.Adapt<VisualDevModelDataConfigOutput>();
var tInfo = new TemplateParsingBase(config);
if (tInfo.AllFieldsModel.Any(x => (x.__config__.defaultCurrent) && (x.__config__.jnpfKey.Equals(JnpfKeyConst.USERSELECT) || x.__config__.jnpfKey.Equals(JnpfKeyConst.DEPSELECT))))
{
var userId = _userManager.UserId;
var depId = _visualDevRepository.AsSugarClient().Queryable<UserEntity>().Where(x => x.Id.Equals(_userManager.UserId)).Select(x => x.OrganizeId).First();
var allUserRelationList = _visualDevRepository.AsSugarClient().Queryable<UserRelationEntity>().Select(x => new UserRelationEntity() { UserId = x.UserId, ObjectId = x.ObjectId }).ToList();
var configData = config.FormData.ToObject<Dictionary<string, object>>();
var columnList = configData["fields"].ToObject<List<Dictionary<string, object>>>();
_runService.FieldBindDefaultValue(ref columnList, userId, depId, allUserRelationList);
configData["fields"] = columnList;
config.FormData = configData.ToJsonString();
configData = config.ColumnData.ToObject<Dictionary<string, object>>();
var searchList = configData["searchList"].ToObject<List<Dictionary<string, object>>>();
columnList = configData["columnList"].ToObject<List<Dictionary<string, object>>>();
_runService.FieldBindDefaultValue(ref searchList, userId, depId, allUserRelationList);
_runService.FieldBindDefaultValue(ref columnList, userId, depId, allUserRelationList);
configData["searchList"] = searchList;
configData["columnList"] = columnList;
config.ColumnData = configData.ToJsonString();
configData = config.AppColumnData.ToObject<Dictionary<string, object>>();
searchList = configData["searchList"].ToObject<List<Dictionary<string, object>>>();
columnList = configData["columnList"].ToObject<List<Dictionary<string, object>>>();
_runService.FieldBindDefaultValue(ref searchList, userId, depId, allUserRelationList);
_runService.FieldBindDefaultValue(ref columnList, userId, depId, allUserRelationList);
configData["searchList"] = searchList;
configData["columnList"] = columnList;
config.AppColumnData = configData.ToJsonString();
}
return config.Adapt<VisualDevModelDataConfigOutput>();
}
#endregion
}
}