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

@@ -7,11 +7,13 @@ using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.FriendlyException;
using JNPF.Systems.Entitys.Dto.ModuleForm;
using JNPF.Systems.Entitys.Model.DataBase;
using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Entitys.System;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev.Engine.Core;
using JNPF.VisualDev.Engine.Model;
using JNPF.VisualDev.Interfaces;
using JNPF.WorkFlow.Entitys.Dto.FlowEngine;
using JNPF.WorkFlow.Entitys.Dto.FlowForm;
@@ -163,6 +165,7 @@ public class FlowFormService : IDynamicApiController, ITransient
entity.EnabledMark = 0;
//entity.TableJson = "[]";
entity.DraftJson = entity.ToJsonString();
entity.LastModifyTime = null;
var result = await _repository.AsSugarClient().Insertable(entity).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
_ = result ?? throw Oops.Oh(ErrorCode.WF0002);
}
@@ -175,19 +178,20 @@ public class FlowFormService : IDynamicApiController, ITransient
[HttpGet("GetFormById/{id}")]
public async Task<dynamic> GetFormById(string id)
{
var entity = await GetInfo(id);
if (entity == null || entity.EnabledMark != 1) throw Oops.Oh(ErrorCode.COM1016);
var tempId = _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().Where(x => x.Id.Equals(entity.FlowId)).Select(x => x.TemplateId).First();
if (tempId == null) throw Oops.Oh(ErrorCode.COM1016);
if (!_repository.AsSugarClient().Queryable<FlowTemplateEntity>().Where(x => x.Id.Equals(tempId) && x.EnabledMark.Equals(1)).Any()) throw Oops.Oh(ErrorCode.COM1017);
var res = await _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity, FlowTemplateEntity>((a, b) => new JoinQueryInfos(JoinType.Left, a.TemplateId == b.Id))
.Select((a, b) => new
{
id = SqlFunc.IIF(b.EnabledMark == 0, null, a.Id),
enCode = b.EnCode,
}).MergeTable().FirstAsync(a => a.id.Equals(entity.FlowId));
if (res == null) throw Oops.Oh(ErrorCode.COM1016);
return res;
var model = new { id = string.Empty, enCode = string.Empty, enabledMark = 0 };
var form = await GetInfo(id);
if (form == null) throw Oops.Oh(ErrorCode.COM1019);
if (form != null && form.FlowId.IsNotEmptyOrNull())
model = _repository.AsSugarClient().Queryable<FlowTemplateEntity>().Where(x => x.Id.Equals(form.FlowId)).Select(x => new { id = x.Id, enCode = x.EnCode, enabledMark = (int)x.EnabledMark }).First();
if (model == null || model.id.IsNullOrEmpty()) throw Oops.Oh(ErrorCode.COM1016);
if (form.FlowType == 1 && form.FormType == 1 && model.enabledMark != 1)
{
// 代码生成的功能流程需要判断流程是否启用。
throw Oops.Oh(ErrorCode.COM1017);
}
return model;
}
#endregion
@@ -372,6 +376,7 @@ public class FlowFormService : IDynamicApiController, ITransient
Id = entity.Id,
State = 1,
WebType = 3,
EnableFlow = 1,
FullName = entity.FullName,
EnCode = entity.EnCode,
FormData = entity.PropertyJson
@@ -387,6 +392,22 @@ public class FlowFormService : IDynamicApiController, ITransient
}
var dbLink = await _runService.GetDbLink(newEntity.DbLinkId);
var MainTable = newEntity.TableJson.ToList<TableModel>().Find(m => m.typeId.Equals("1")); // 主表
if (MainTable != null)
{
if (!_dataBaseManager.IsAnyColumn(dbLink, MainTable?.table, "f_flowtaskid"))
{
var pFieldList = new List<DbTableFieldModel>() { new DbTableFieldModel() { field = "F_FlowTaskId", fieldName = "流程任务Id", dataType = "varchar", dataLength = "50", allowNull = 1 } };
_dataBaseManager.AddTableColumn(dbLink, MainTable?.table, pFieldList);
}
if (!_dataBaseManager.IsAnyColumn(dbLink, MainTable?.table, "f_flowid"))
{
var pFieldList = new List<DbTableFieldModel>() { new DbTableFieldModel() { field = "F_FlowId", fieldName = "流程引擎Id", dataType = "varchar", dataLength = "50", allowNull = 1 } };
_dataBaseManager.AddTableColumn(dbLink, MainTable?.table, pFieldList);
}
}
entity.DraftJson = entity.ToJsonString();
entity.EnabledMark = 1;
var isOk = await _repository.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(x => x.LastModify()).ExecuteCommandHasChangeAsync();