v3.4.6
This commit is contained in:
@@ -13,6 +13,7 @@ using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.Permission;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.WorkFlow.Entitys.Dto.FlowTemplate;
|
||||
using JNPF.WorkFlow.Entitys.Entity;
|
||||
using JNPF.WorkFlow.Entitys.Model;
|
||||
@@ -36,7 +37,6 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
private readonly ISqlSugarRepository<FlowTemplateEntity> _repository;
|
||||
private readonly IFlowTaskRepository _flowTaskRepository;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
private readonly IUserRelationService _userRelationService;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IFileManager _fileManager;
|
||||
private readonly ITenant _db;
|
||||
@@ -45,7 +45,6 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
ISqlSugarRepository<FlowTemplateEntity> repository,
|
||||
IFlowTaskRepository flowTaskRepository,
|
||||
IDictionaryDataService dictionaryDataService,
|
||||
IUserRelationService userRelationService,
|
||||
IUserManager userManager,
|
||||
IFileManager fileManager,
|
||||
ISqlSugarClient context)
|
||||
@@ -53,7 +52,6 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
_repository = repository;
|
||||
_flowTaskRepository = flowTaskRepository;
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
_userRelationService = userRelationService;
|
||||
_userManager = userManager;
|
||||
_fileManager = fileManager;
|
||||
_db = context.AsTenant();
|
||||
@@ -70,12 +68,12 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
public async Task<dynamic> GetList([FromQuery] FlowTemplateListQuery input)
|
||||
{
|
||||
var objList = _flowTaskRepository.GetCurrentUserObjId();
|
||||
var list = await _repository.AsSugarClient().Queryable<FlowTemplateEntity, FlowTemplateJsonEntity, FlowEngineVisibleEntity>((a, b, c) => new JoinQueryInfos(JoinType.Left, a.Id == b.TemplateId, JoinType.Left, a.Id == c.FlowId))
|
||||
.Where((a, b) => a.DeleteMark == null && b.DeleteMark == null && b.EnabledMark == 1)
|
||||
.WhereIF(_userManager.User.IsAdministrator == 0, (a, b, c) => a.CreatorUserId == _userManager.UserId || (objList.Contains(c.OperatorId) && c.Type == "2"))
|
||||
var list = await _repository.AsSugarClient().Queryable<FlowTemplateEntity, FlowEngineVisibleEntity>((a, b) => new JoinQueryInfos(JoinType.Left, a.Id == b.FlowId))
|
||||
.Where(a => a.DeleteMark == null)
|
||||
.WhereIF(_userManager.User.IsAdministrator == 0, (a, b) => a.CreatorUserId == _userManager.UserId || (objList.Contains(b.OperatorId) && b.Type == "2"))
|
||||
.WhereIF(input.category.IsNotEmptyOrNull(), a => a.Category == input.category)
|
||||
.WhereIF(input.keyword.IsNotEmptyOrNull(), a => a.FullName.Contains(input.keyword) || a.EnCode.Contains(input.keyword))
|
||||
.Select((a, b) => new FlowTemplateListOutput
|
||||
.Select(a => new FlowTemplateListOutput
|
||||
{
|
||||
category = SqlFunc.Subqueryable<DictionaryDataEntity>().Where(d => d.Id == a.Category).Select(d => d.FullName),
|
||||
id = a.Id,
|
||||
@@ -90,8 +88,6 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
lastModifyUser = SqlFunc.Subqueryable<UserEntity>().Where(u => u.Id == a.LastModifyUserId).Select(u => SqlFunc.MergeString(u.RealName, "/", u.Account)),
|
||||
sortCode = a.SortCode,
|
||||
type = a.Type,
|
||||
visibleType = b.VisibleType,
|
||||
version = b.Version,
|
||||
hasAssistBtn = SqlFunc.IIF((_userManager.UserId == a.CreatorUserId || _userManager.User.IsAdministrator == 1), 1, 0),
|
||||
}).Distinct().MergeTable().OrderBy(a => a.sortCode).OrderBy(a => a.creatorTime, OrderByType.Desc)
|
||||
.OrderByIF(!string.IsNullOrEmpty(input.keyword), t => t.lastModifyTime, OrderByType.Desc).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
@@ -105,11 +101,25 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
[HttpGet("ListAll")]
|
||||
public async Task<dynamic> GetListAll()
|
||||
{
|
||||
var list1 = await GetFlowFormList(0);
|
||||
foreach (var item in list1)
|
||||
{
|
||||
item.id = item.templateId;
|
||||
}
|
||||
//var list1 = await GetFlowFormList(0);
|
||||
var list1 = await _repository.AsSugarClient().Queryable<FlowTemplateEntity>()
|
||||
.Where(a => a.DeleteMark == null && a.EnabledMark == 1)
|
||||
.Select(a => new FlowTemplateTreeOutput
|
||||
{
|
||||
id = a.Id,
|
||||
creatorTime = a.CreatorTime,
|
||||
enCode = a.EnCode,
|
||||
enabledMark = a.EnabledMark,
|
||||
fullName = a.FullName,
|
||||
icon = a.Icon,
|
||||
iconBackground = a.IconBackground,
|
||||
lastModifyTime = a.LastModifyTime,
|
||||
sortCode = a.SortCode,
|
||||
parentId = a.Category,
|
||||
category = a.Category,
|
||||
type = a.Type,
|
||||
}).Distinct().MergeTable().OrderBy(a => a.sortCode).OrderBy(a => a.creatorTime, OrderByType.Desc)
|
||||
.OrderBy(t => t.lastModifyTime, OrderByType.Desc).ToListAsync();
|
||||
if (list1.Any())
|
||||
{
|
||||
var dicDataInfo = await _dictionaryDataService.GetInfo(list1.FirstOrDefault().parentId);
|
||||
@@ -143,22 +153,41 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
[HttpGet("PageListAll")]
|
||||
public async Task<dynamic> GetListPageAll([FromQuery] FlowTemplateListQuery input)
|
||||
{
|
||||
var data = await GetFlowFormList(input.flowType.ParseToInt());
|
||||
if (input.category.IsNotEmptyOrNull())
|
||||
data = data.FindAll(x => x.category == input.category);
|
||||
if (input.keyword.IsNotEmptyOrNull())
|
||||
data = data.FindAll(o => o.fullName.Contains(input.keyword) || o.enCode.Contains(input.keyword));
|
||||
var pageList = new SqlSugarPagedList<FlowTemplateTreeOutput>()
|
||||
{
|
||||
list = data.Skip((input.currentPage - 1) * input.pageSize).Take(input.pageSize).ToList(),
|
||||
pagination = new Pagination()
|
||||
//var data = await GetFlowFormList(input.flowType.ParseToInt());
|
||||
//if (input.category.IsNotEmptyOrNull())
|
||||
// data = data.FindAll(x => x.category == input.category);
|
||||
//if (input.keyword.IsNotEmptyOrNull())
|
||||
// data = data.FindAll(o => o.fullName.Contains(input.keyword) || o.enCode.Contains(input.keyword));
|
||||
//var pageList = new SqlSugarPagedList<FlowTemplateTreeOutput>()
|
||||
//{
|
||||
// list = data.Skip((input.currentPage - 1) * input.pageSize).Take(input.pageSize).ToList(),
|
||||
// pagination = new Pagination()
|
||||
// {
|
||||
// PageIndex = input.currentPage,
|
||||
// PageSize = input.pageSize,
|
||||
// Total = data.Count
|
||||
// }
|
||||
//};
|
||||
//return PageResult<FlowTemplateTreeOutput>.SqlSugarPageResult(pageList);
|
||||
var list = await _repository.AsSugarClient().Queryable<FlowTemplateEntity>()
|
||||
.Where(a => a.DeleteMark == null && a.Type == 0 && a.EnabledMark == 1)
|
||||
.WhereIF(input.category.IsNotEmptyOrNull(), a => a.Category == input.category)
|
||||
.WhereIF(input.keyword.IsNotEmptyOrNull(), a => a.FullName.Contains(input.keyword) || a.EnCode.Contains(input.keyword))
|
||||
.Select(a => new FlowTemplateListOutput
|
||||
{
|
||||
CurrentPage = input.currentPage,
|
||||
PageSize = input.pageSize,
|
||||
Total = data.Count
|
||||
}
|
||||
};
|
||||
return PageResult<FlowTemplateTreeOutput>.SqlSugarPageResult(pageList);
|
||||
id = a.Id,
|
||||
creatorTime = a.CreatorTime,
|
||||
enCode = a.EnCode,
|
||||
enabledMark = a.EnabledMark,
|
||||
fullName = a.FullName,
|
||||
icon = a.Icon,
|
||||
iconBackground = a.IconBackground,
|
||||
lastModifyTime = a.LastModifyTime,
|
||||
sortCode = a.SortCode,
|
||||
type = a.Type,
|
||||
}).Distinct().MergeTable().OrderBy(a => a.sortCode).OrderBy(a => a.creatorTime, OrderByType.Desc)
|
||||
.OrderByIF(!string.IsNullOrEmpty(input.keyword), t => t.lastModifyTime, OrderByType.Desc).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
return PageResult<FlowTemplateListOutput>.SqlSugarPageResult(list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -169,8 +198,23 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
[HttpGet("{id}/FlowJsonList")]
|
||||
public async Task<dynamic> GetFlowJsonList(string id, [FromQuery] FlowTemplateListQuery input)
|
||||
{
|
||||
var flowJosnEntity = await _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().FirstAsync(x => x.Id == input.flowId && x.DeleteMark == null);
|
||||
if (flowJosnEntity.IsNullOrEmpty())
|
||||
{
|
||||
var pageList = new SqlSugarPagedList<FlowTemplateJsonInfoOutput>()
|
||||
{
|
||||
list = new List<FlowTemplateJsonInfoOutput>(),
|
||||
pagination = new Pagination()
|
||||
{
|
||||
CurrentPage = input.currentPage,
|
||||
PageSize = input.pageSize,
|
||||
Total = 0
|
||||
}
|
||||
};
|
||||
return PageResult<FlowTemplateJsonInfoOutput>.SqlSugarPageResult(pageList);
|
||||
}
|
||||
var whereLambda = LinqExpression.And<FlowTemplateJsonEntity>();
|
||||
whereLambda = whereLambda.And(x => x.DeleteMark == null && x.TemplateId == id);
|
||||
whereLambda = whereLambda.And(x => x.DeleteMark == null && x.TemplateId == flowJosnEntity.TemplateId && x.FullName == flowJosnEntity.FullName);
|
||||
var start = new DateTime();
|
||||
var end = new DateTime();
|
||||
if (input.endTime != null && input.startTime != null)
|
||||
@@ -188,13 +232,14 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
.Select((a) => new FlowTemplateJsonInfoOutput
|
||||
{
|
||||
id = a.Id,
|
||||
fullName = a.FullName,
|
||||
version = a.Version,
|
||||
enabledMark = a.EnabledMark,
|
||||
creatorUser = SqlFunc.Subqueryable<UserEntity>().Where(u => u.Id == a.CreatorUserId).Select(u => SqlFunc.MergeString(u.RealName, "/", u.Account)),
|
||||
creatorTime = a.CreatorTime,
|
||||
lastModifyTime = a.LastModifyTime,
|
||||
flowTemplateJson = a.FlowTemplateJson,
|
||||
}).MergeTable().OrderBy(a => a.creatorTime, OrderByType.Desc)
|
||||
}).MergeTable().OrderBy(a => a.enabledMark, OrderByType.Desc).OrderBy(a => a.creatorTime, OrderByType.Desc)
|
||||
.OrderByIF(!string.IsNullOrEmpty(input.keyword), t => t.lastModifyTime, OrderByType.Desc).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
return PageResult<FlowTemplateJsonInfoOutput>.SqlSugarPageResult(list);
|
||||
}
|
||||
@@ -207,8 +252,32 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
[HttpGet("{id}")]
|
||||
public async Task<dynamic> GetInfo(string id)
|
||||
{
|
||||
//var output = (await _repository.GetFirstAsync(x => x.Id == id && x.DeleteMark == null)).Adapt<FlowTemplateInfoOutput>();
|
||||
//output.onlineDev = _repository.AsSugarClient().Queryable<VisualDevEntity>().Any(x => x.Id == id && x.DeleteMark == null);
|
||||
//var flowJsonList = await _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().Where(x => x.TemplateId == id && x.EnabledMark == 1 && x.DeleteMark == null).Select(x => new { id = x.Id, flowId = x.Id, fullName = x.FullName, flowTemplateJson = x.FlowTemplateJson }).ToListAsync();
|
||||
//output.flowTemplateJson = flowJsonList.ToJsonString();
|
||||
//return output;
|
||||
var output = (await _repository.GetFirstAsync(x => x.Id == id && x.DeleteMark == null)).Adapt<FlowTemplateInfoOutput>();
|
||||
output.flowTemplateJson = _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().First(x => x.TemplateId == id && x.EnabledMark == 1 && x.DeleteMark == null)?.FlowTemplateJson;
|
||||
var flowFormEntity = _repository.AsSugarClient().Queryable<FlowFormEntity>().First(x => x.FlowId == id && x.FlowType == 1 && x.FormType == 2 && x.DeleteMark == null);
|
||||
if (flowFormEntity.IsNotEmptyOrNull())
|
||||
{
|
||||
output.onlineDev = true;
|
||||
output.onlineFormId = flowFormEntity.Id;
|
||||
}
|
||||
var flowJsonList = new List<FlowJsonInfo>();
|
||||
var flowTemplateJsonEntityList = await _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().Where(x => x.TemplateId == id && x.EnabledMark == 1 && x.DeleteMark == null).OrderBy(x => x.SortCode).ToListAsync();
|
||||
foreach (var item in flowTemplateJsonEntityList)
|
||||
{
|
||||
var flowJosn = new FlowJsonInfo();
|
||||
flowJosn.id = item.Id;
|
||||
flowJosn.flowId = item.Id;
|
||||
flowJosn.fullName = item.FullName;
|
||||
var flowIds = _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().Where(x => x.GroupId == item.GroupId && x.DeleteMark == null).Select(x => x.Id).ToList();
|
||||
flowJosn.isDelete = await _flowTaskRepository.AnyFlowTask(x => x.DeleteMark == null && flowIds.Contains(x.FlowId));
|
||||
flowJosn.flowTemplateJson = item.FlowTemplateJson?.ToObject<FlowTemplateJsonModel>();
|
||||
flowJsonList.Add(flowJosn);
|
||||
}
|
||||
output.flowTemplateJson = flowJsonList.ToJsonString();
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -245,6 +314,29 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
return new { list = output };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表(子流程选择流程).
|
||||
/// </summary>
|
||||
/// <param name="type">(预留字段).</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("PageChildListAll")]
|
||||
public async Task<dynamic> PageChildListAll([FromQuery] FlowTemplateListQuery input)
|
||||
{
|
||||
var list = await _repository.AsSugarClient().Queryable<FlowTemplateEntity, FlowTemplateJsonEntity>((a, b) => new JoinQueryInfos(JoinType.Right, a.Id == b.TemplateId))
|
||||
.Where((a, b) => a.DeleteMark == null && a.EnabledMark == 1 && a.Type == input.flowType && b.DeleteMark == null && b.EnabledMark == 1)
|
||||
.WhereIF(input.keyword.IsNotEmptyOrNull(), (a, b) => b.FullName.Contains(input.keyword))
|
||||
.Select((a, b) => new FlowTemplateTreeOutput
|
||||
{
|
||||
id = b.Id,
|
||||
fullName = b.FullName,
|
||||
creatorTime = a.CreatorTime,
|
||||
lastModifyTime = a.LastModifyTime,
|
||||
sortCode = a.SortCode,
|
||||
}).MergeTable().OrderBy(a => a.sortCode).OrderBy(a => a.creatorTime, OrderByType.Desc)
|
||||
.OrderBy(a => a.lastModifyTime, OrderByType.Desc).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
return PageResult<FlowTemplateTreeOutput>.SqlSugarPageResult(list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出.
|
||||
/// </summary>
|
||||
@@ -255,8 +347,9 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
{
|
||||
var importModel = new FlowTemplateImportOutput();
|
||||
importModel.flowTemplate = await _repository.GetFirstAsync(x => x.Id == id && x.DeleteMark == null);
|
||||
importModel.flowTemplateJson = await _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().FirstAsync(x => x.TemplateId == id && x.EnabledMark == 1 && x.DeleteMark == null);
|
||||
importModel.visibleList = await _repository.AsSugarClient().Queryable<FlowEngineVisibleEntity>().Where(x => x.FlowId == importModel.flowTemplateJson.Id).ToListAsync();
|
||||
importModel.flowTemplateJson = await _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().Where(x => x.TemplateId == id && x.EnabledMark == 1 && x.DeleteMark == null).ToListAsync();
|
||||
var flowJsonIds = importModel.flowTemplateJson.Select(x => x.Id).ToList();
|
||||
importModel.visibleList = await _repository.AsSugarClient().Queryable<FlowEngineVisibleEntity>().Where(x => flowJsonIds.Contains(x.FlowId)).ToListAsync();
|
||||
var jsonStr = importModel.ToJsonString();
|
||||
return await _fileManager.Export(jsonStr, importModel.flowTemplate.FullName, ExportFileType.ffe);
|
||||
}
|
||||
@@ -333,9 +426,34 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
{
|
||||
var entity = await _repository.GetFirstAsync(x => x.EnCode == code && x.DeleteMark == null);
|
||||
if (entity == null) Oops.Oh(ErrorCode.COM1005);
|
||||
var jsonEntity = await _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().FirstAsync(x => x.TemplateId == entity.Id && x.EnabledMark == 1 && x.DeleteMark == null);
|
||||
if (jsonEntity == null) Oops.Oh(ErrorCode.COM1005);
|
||||
return jsonEntity.Id;
|
||||
return entity.Id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发起流程列表(下拉).
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("FlowJsonList/{teplateId}")]
|
||||
public async Task<dynamic> GetFlowJsonList(string teplateId, string type)
|
||||
{
|
||||
var flowJsonList = (await _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().Where(x => x.TemplateId == teplateId && x.EnabledMark == 1 && x.DeleteMark == null).OrderBy(x => x.SortCode).ToListAsync()).Adapt<List<FlowTemplateJsonInfoOutput>>();
|
||||
if (!flowJsonList.Any()) throw Oops.Oh(ErrorCode.COM1016);
|
||||
if (!_userManager.IsAdministrator && type == "1")
|
||||
{
|
||||
// 判断当前用户是否有发起权限
|
||||
foreach (var item in flowJsonList.FindAll(x => x.visibleType == 1))
|
||||
{
|
||||
// 指定发起人.
|
||||
var visibleUserList = await _repository.AsSugarClient().Queryable<FlowEngineVisibleEntity, UserRelationEntity>((a, b) => new JoinQueryInfos(JoinType.Left, a.OperatorId == b.ObjectId || a.OperatorId == b.UserId))
|
||||
.Where((a, b) => a.FlowId == item.id && a.Type == "1").Select((a, b) => b.UserId).Distinct().ToListAsync();
|
||||
if (!visibleUserList.Contains(_userManager.UserId))
|
||||
{
|
||||
flowJsonList.Remove(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!flowJsonList.Any()) throw Oops.Oh(ErrorCode.WF0049);
|
||||
return flowJsonList;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -355,11 +473,13 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
var flowTemplateJsonIdList = await _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().Where(x => x.TemplateId == id).Select(x => x.Id).ToListAsync();
|
||||
if (await _flowTaskRepository.AnyFlowTask(x => x.DeleteMark == null && flowTemplateJsonIdList.Contains(x.FlowId)))
|
||||
throw Oops.Oh(ErrorCode.WF0037);
|
||||
if (await _repository.AsSugarClient().Queryable<FlowFormEntity>().AnyAsync(x => x.FlowId == id))
|
||||
throw Oops.Oh(ErrorCode.WF0052);
|
||||
_db.BeginTran();
|
||||
await _repository.AsSugarClient().Deleteable<FlowEngineVisibleEntity>(a => flowTemplateJsonIdList.Contains(a.FlowId)).ExecuteCommandHasChangeAsync();
|
||||
await _repository.AsSugarClient().Deleteable<FlowFormRelationEntity>(a => flowTemplateJsonIdList.Contains(a.FlowId)).ExecuteCommandHasChangeAsync();
|
||||
await _repository.AsSugarClient().Deleteable<FlowTemplateJsonEntity>(a => flowTemplateJsonIdList.Contains(a.Id)).ExecuteCommandHasChangeAsync();
|
||||
await _repository.AsSugarClient().Updateable<FlowFormEntity>().SetColumns(x => x.FlowId == null).Where(x => flowTemplateJsonIdList.Contains(x.FlowId)).ExecuteCommandAsync();
|
||||
await _repository.AsSugarClient().Deleteable<FlowFormRelationEntity>(a => a.FlowId == id).ExecuteCommandHasChangeAsync();
|
||||
await _repository.AsSugarClient().Updateable<FlowFormEntity>().SetColumns(x => x.FlowId == null).Where(x => x.FlowId == id).ExecuteCommandAsync();
|
||||
var isOk = await _repository.AsUpdateable(flowTemplateEntity).CallEntityMethod(m => m.Delete()).UpdateColumns(it => new { it.DeleteMark, it.DeleteTime, it.DeleteUserId }).ExecuteCommandHasChangeAsync();
|
||||
_db.CommitTran();
|
||||
if (!isOk)
|
||||
@@ -393,7 +513,7 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
if (await _repository.IsAnyAsync(x => x.Id != id && (x.EnCode == input.enCode || x.FullName == input.fullName) && x.DeleteMark == null))
|
||||
throw Oops.Oh(ErrorCode.COM1004);
|
||||
var flowTemplateEntity = input.Adapt<FlowTemplateEntity>();
|
||||
var result = await Update(flowTemplateEntity, input.flowTemplateJson);
|
||||
var result = await Update(flowTemplateEntity, input.flowTemplateJson, input.onlineFormId);
|
||||
if (result.IsNullOrEmpty())
|
||||
throw Oops.Oh(ErrorCode.COM1001);
|
||||
return result;
|
||||
@@ -410,13 +530,24 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
var entity = await _repository.GetFirstAsync(x => x.Id == id && x.DeleteMark == null);
|
||||
if (entity == null)
|
||||
throw Oops.Oh(ErrorCode.COM1005);
|
||||
var flowTemplateJsonEntity = await _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().FirstAsync(x => x.TemplateId == id && x.EnabledMark == 1 && x.DeleteMark == null);
|
||||
var random = RandomExtensions.NextLetterAndNumberString(new Random(), 5).ToLower();
|
||||
entity.FullName = string.Format("{0}副本{1}", entity.FullName, random);
|
||||
entity.EnCode = string.Format("{0}{1}", entity.EnCode, random);
|
||||
if (entity.FullName.Length >= 50 || entity.EnCode.Length >= 50)
|
||||
throw Oops.Oh(ErrorCode.COM1009);
|
||||
var result = await Create(entity, flowTemplateJsonEntity.FlowTemplateJson);
|
||||
var flowJsonList = new List<FlowJsonInfo>();
|
||||
var flowTemplateJsonEntityList = await _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().Where(x => x.TemplateId == id && x.EnabledMark == 1 && x.DeleteMark == null).ToListAsync();
|
||||
foreach (var item in flowTemplateJsonEntityList)
|
||||
{
|
||||
var flowJosn = new FlowJsonInfo();
|
||||
flowJosn.id = item.Id;
|
||||
flowJosn.flowId = item.Id;
|
||||
flowJosn.fullName = item.FullName;
|
||||
flowJosn.isDelete = await _flowTaskRepository.AnyFlowTask(x => x.DeleteMark == null && x.FlowId == item.Id);
|
||||
flowJosn.flowTemplateJson = item.FlowTemplateJson?.ToObject<FlowTemplateJsonModel>();
|
||||
flowJsonList.Add(flowJosn);
|
||||
}
|
||||
var result = await Create(entity, flowJsonList.ToJsonString());
|
||||
_ = result ?? throw Oops.Oh(ErrorCode.WF0002);
|
||||
}
|
||||
|
||||
@@ -494,11 +625,24 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
[HttpPost("{id}/MainVersion")]
|
||||
public async Task MainVersion(string id)
|
||||
{
|
||||
var jsonInfo = await _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().FirstAsync(x => x.Id == id && x.DeleteMark == null);
|
||||
await _repository.AsSugarClient().Updateable<FlowTemplateJsonEntity>().SetColumns(it => it.EnabledMark == 0).Where(it => it.Id != id && it.TemplateId == jsonInfo.TemplateId).ExecuteCommandHasChangeAsync();
|
||||
var isOk = await _repository.AsSugarClient().Updateable<FlowTemplateJsonEntity>().SetColumns(it => it.EnabledMark == 1).Where(it => it.Id == id && it.TemplateId == jsonInfo.TemplateId).ExecuteCommandHasChangeAsync();
|
||||
if (!isOk)
|
||||
throw Oops.Oh(ErrorCode.COM1003);
|
||||
foreach (var item in id.Split(","))
|
||||
{
|
||||
var jsonInfo = await _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().FirstAsync(x => x.Id == item && x.DeleteMark == null);
|
||||
await _repository.AsSugarClient().Updateable<FlowTemplateJsonEntity>().SetColumns(it => new FlowTemplateJsonEntity()
|
||||
{
|
||||
EnabledMark = 0,
|
||||
LastModifyUserId = _userManager.UserId,
|
||||
LastModifyTime = SqlFunc.GetDate()
|
||||
}).Where(it => it.EnabledMark == 1 && it.TemplateId == jsonInfo.TemplateId && it.FullName == jsonInfo.FullName).ExecuteCommandHasChangeAsync();
|
||||
var isOk = await _repository.AsSugarClient().Updateable<FlowTemplateJsonEntity>().SetColumns(it => new FlowTemplateJsonEntity()
|
||||
{
|
||||
EnabledMark = 1,
|
||||
LastModifyUserId = _userManager.UserId,
|
||||
LastModifyTime = SqlFunc.GetDate()
|
||||
}).Where(it => it.Id == item && it.TemplateId == jsonInfo.TemplateId && it.FullName == jsonInfo.FullName).ExecuteCommandHasChangeAsync();
|
||||
if (!isOk)
|
||||
throw Oops.Oh(ErrorCode.COM1003);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -511,9 +655,11 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
{
|
||||
if (await _flowTaskRepository.AnyFlowTask(x => x.DeleteMark == null && x.FlowId == id))
|
||||
throw Oops.Oh(ErrorCode.WF0037);
|
||||
var jsonInfo = await _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().FirstAsync(x => x.Id == id && x.DeleteMark == null);
|
||||
var launchFormIdList = new List<string>();
|
||||
GetFormIdList(jsonInfo.FlowTemplateJson.ToObject<FlowTemplateJsonModel>(), launchFormIdList);
|
||||
await _repository.AsSugarClient().Deleteable<FlowFormRelationEntity>(a => a.FlowId == id && launchFormIdList.Contains(a.FormId)).ExecuteCommandHasChangeAsync();
|
||||
var isOk = await _repository.AsSugarClient().Updateable<FlowTemplateJsonEntity>().SetColumns(it => new FlowTemplateJsonEntity() { DeleteMark = 1, DeleteTime = SqlFunc.GetDate(), DeleteUserId = _userManager.UserId }).Where(it => it.Id == id).ExecuteCommandHasChangeAsync();
|
||||
await _repository.AsSugarClient().Deleteable<FlowFormRelationEntity>(a => a.FlowId == id).ExecuteCommandHasChangeAsync();
|
||||
await _repository.AsSugarClient().Updateable<FlowFormEntity>().SetColumns(x => x.FlowId == null).Where(x => x.FlowId==id).ExecuteCommandAsync();
|
||||
if (!isOk)
|
||||
throw Oops.Oh(ErrorCode.COM1003);
|
||||
}
|
||||
@@ -597,46 +743,65 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
_db.BeginTran();
|
||||
var formIdList = new List<string>();
|
||||
entity.Id = SnowflakeIdHelper.NextId();
|
||||
entity.EnabledMark = entity.EnabledMark == null ? 0 : entity.EnabledMark;
|
||||
var flowTemplateJsonEntity = new FlowTemplateJsonEntity();
|
||||
flowTemplateJsonEntity.Id = SnowflakeIdHelper.NextId();
|
||||
flowTemplateJsonEntity.TemplateId = entity.Id;
|
||||
flowTemplateJsonEntity.Version = "1";
|
||||
flowTemplateJsonEntity.FlowTemplateJson = flowTemplateJson;
|
||||
entity.EnabledMark = 0;
|
||||
if (flowTemplateJson.IsNotEmptyOrNull())
|
||||
{
|
||||
var visibleList = GetFlowEngineVisibleList(flowTemplateJson);
|
||||
flowTemplateJsonEntity.VisibleType = visibleList.Count == 0 ? 0 : 1;
|
||||
foreach (var item in visibleList)
|
||||
var index = 0;
|
||||
foreach (var item in flowTemplateJson.ToObject<List<FlowJsonInfo>>())
|
||||
{
|
||||
item.FlowId = flowTemplateJsonEntity.Id;
|
||||
item.SortCode = visibleList.IndexOf(item);
|
||||
item.Type = "1";
|
||||
}
|
||||
if (visibleList.Count > 0)
|
||||
await _repository.AsSugarClient().Insertable(visibleList).CallEntityMethod(m => m.Creator()).ExecuteCommandAsync();
|
||||
|
||||
#region 功能流程则要回写到对应的表单表中
|
||||
GetFormIdList(flowTemplateJson.ToObject<FlowTemplateJsonModel>(), formIdList);
|
||||
foreach (var item in formIdList)
|
||||
{
|
||||
var formRelationEntity = new FlowFormRelationEntity
|
||||
var flowTemplateJsonEntity = new FlowTemplateJsonEntity();
|
||||
flowTemplateJsonEntity.Id = SnowflakeIdHelper.NextId();
|
||||
flowTemplateJsonEntity.TemplateId = entity.Id;
|
||||
flowTemplateJsonEntity.Version = "1";
|
||||
flowTemplateJsonEntity.FlowTemplateJson = item.flowTemplateJson.ToJsonString();
|
||||
flowTemplateJsonEntity.FullName = item.fullName;
|
||||
flowTemplateJsonEntity.SortCode = index++;
|
||||
flowTemplateJsonEntity.GroupId = SnowflakeIdHelper.NextId();
|
||||
var visibleList = GetFlowEngineVisibleList(item.flowTemplateJson.ToJsonString());
|
||||
flowTemplateJsonEntity.VisibleType = visibleList.Count == 0 ? 0 : 1;
|
||||
foreach (var visible in visibleList)
|
||||
{
|
||||
Id = SnowflakeIdHelper.NextId(),
|
||||
FlowId = flowTemplateJsonEntity.Id,
|
||||
FormId = item
|
||||
};
|
||||
await _repository.AsSugarClient().Insertable(formRelationEntity).ExecuteReturnEntityAsync();
|
||||
visible.FlowId = flowTemplateJsonEntity.Id;
|
||||
visible.SortCode = visibleList.IndexOf(visible);
|
||||
visible.Type = "1";
|
||||
}
|
||||
if (visibleList.Count > 0)
|
||||
await _repository.AsSugarClient().Insertable(visibleList).CallEntityMethod(m => m.Creator()).ExecuteCommandAsync();
|
||||
await _repository.AsSugarClient().Insertable(flowTemplateJsonEntity).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
|
||||
#region 功能流程则要回写到对应的表单表中
|
||||
if (entity.Type == 1)
|
||||
{
|
||||
var formId = item.flowTemplateJson.properties.ToObject<StartProperties>()?.formId;
|
||||
if (formIdList.Any() && !formIdList.Contains(formId))
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.WF0043);
|
||||
}
|
||||
else
|
||||
{
|
||||
formIdList.Add(formId);
|
||||
}
|
||||
if (await _repository.AsSugarClient().Queryable<FlowFormEntity>().AnyAsync(x => x.Id == formId && x.FlowId != entity.Id && !SqlFunc.IsNullOrEmpty(x.FlowId)))
|
||||
throw Oops.Oh(ErrorCode.WF0043);
|
||||
await _repository.AsSugarClient().Updateable<FlowFormEntity>().SetColumns(x => x.FlowId == entity.Id).Where(x => x.Id == formId).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
var launchFormIdList = new List<string>();
|
||||
GetFormIdList(item.flowTemplateJson, launchFormIdList);
|
||||
foreach (var launchFormId in launchFormIdList)
|
||||
{
|
||||
var formRelationEntity = new FlowFormRelationEntity
|
||||
{
|
||||
Id = SnowflakeIdHelper.NextId(),
|
||||
FlowId = entity.Id,
|
||||
FormId = launchFormId
|
||||
};
|
||||
await _repository.AsSugarClient().Insertable(formRelationEntity).ExecuteReturnEntityAsync();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
if (entity.Type == 1)
|
||||
{
|
||||
if (await _repository.AsSugarClient().Queryable<FlowFormEntity>().AnyAsync(x => x.Id == formIdList.FirstOrDefault() && !SqlFunc.IsNullOrEmpty(x.FlowId)))
|
||||
throw Oops.Oh(ErrorCode.WF0043);
|
||||
await _repository.AsSugarClient().Updateable<FlowFormEntity>().SetColumns(x => x.FlowId == flowTemplateJsonEntity.Id).Where(x => x.Id == formIdList.FirstOrDefault()).ExecuteCommandAsync();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
await _repository.AsSugarClient().Insertable(flowTemplateJsonEntity).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
|
||||
var result = await _repository.AsSugarClient().Insertable(entity).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
|
||||
if (result == null)
|
||||
throw Oops.Oh(ErrorCode.COM1005);
|
||||
@@ -657,75 +822,134 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
/// <param name="visibleList">可见范围.</param>
|
||||
/// <returns></returns>
|
||||
[NonAction]
|
||||
private async Task<object> Update(FlowTemplateEntity entity, string flowTemplateJson)
|
||||
private async Task<object> Update(FlowTemplateEntity entity, string flowTemplateJson, string onlineFormId)
|
||||
{
|
||||
try
|
||||
{
|
||||
_db.BeginTran();
|
||||
var flag = false;
|
||||
var isMainVersionId = new List<string>();
|
||||
var formIdList = new List<string>();
|
||||
var flowTemplateJsonEntity = await _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().FirstAsync(x => x.TemplateId == entity.Id && x.DeleteMark == null && x.EnabledMark == 1);
|
||||
if (flowTemplateJsonEntity.FlowTemplateJson.IsNotEmptyOrNull())
|
||||
{
|
||||
// 清空就模板关联表单数据
|
||||
string oldFormId = flowTemplateJsonEntity.FlowTemplateJson.ToObject<FlowTemplateJsonModel>().properties.ToObject<StartProperties>().formId;
|
||||
await _repository.AsSugarClient().Updateable<FlowFormEntity>().SetColumns(x => x.FlowId == null).Where(x => x.Id == oldFormId).ExecuteCommandAsync();
|
||||
await _repository.AsSugarClient().Deleteable<FlowFormRelationEntity>().Where(x => x.FlowId == flowTemplateJsonEntity.Id).ExecuteCommandAsync();
|
||||
|
||||
}
|
||||
var isCreate = flowTemplateJsonEntity.FlowTemplateJson.Equals(flowTemplateJson);//流程json是否变更
|
||||
flowTemplateJsonEntity.FlowTemplateJson = flowTemplateJson;
|
||||
var groupIdList = new List<string>(); // 未删除的分组id.
|
||||
if (flowTemplateJson.IsNotEmptyOrNull())
|
||||
{
|
||||
var visibleList = GetFlowEngineVisibleList(flowTemplateJson);
|
||||
flowTemplateJsonEntity.VisibleType = visibleList.Count == 0 ? 0 : 1;
|
||||
if ((await _flowTaskRepository.AnyFlowTask(x => x.DeleteMark == null && x.FlowId == flowTemplateJsonEntity.Id)) && !isCreate)
|
||||
var index = 0;
|
||||
foreach (var item in flowTemplateJson.ToObject<List<FlowJsonInfo>>())
|
||||
{
|
||||
flag = true;
|
||||
flowTemplateJsonEntity.Version = ((await _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().Where(x => x.TemplateId == entity.Id).Select(x => SqlFunc.AggregateMax(SqlFunc.ToInt64(x.Version))).FirstAsync()).ParseToInt() + 1).ToString();
|
||||
flowTemplateJsonEntity.Id = SnowflakeIdHelper.NextId();
|
||||
flowTemplateJsonEntity.EnabledMark = 0;
|
||||
await _repository.AsSugarClient().Insertable(flowTemplateJsonEntity).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await _repository.AsSugarClient().Updateable(flowTemplateJsonEntity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandHasChangeAsync();
|
||||
await _repository.AsSugarClient().Deleteable<FlowEngineVisibleEntity>(a => a.FlowId == flowTemplateJsonEntity.Id).ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
foreach (var item in visibleList)
|
||||
{
|
||||
item.FlowId = flowTemplateJsonEntity.Id;
|
||||
item.SortCode = visibleList.IndexOf(item);
|
||||
item.Type = "1";
|
||||
}
|
||||
if (visibleList.Count > 0)
|
||||
await _repository.AsSugarClient().Insertable(visibleList).CallEntityMethod(m => m.Creator()).ExecuteCommandAsync();
|
||||
GetFormIdList(flowTemplateJson.ToObject<FlowTemplateJsonModel>(), formIdList);
|
||||
foreach (var item in formIdList)
|
||||
{
|
||||
var formRelationEntity = new FlowFormRelationEntity
|
||||
var flowTemplateJsonEntity = await _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().FirstAsync(x => x.Id == item.id && x.DeleteMark == null);
|
||||
var visibleList = GetFlowEngineVisibleList(item.flowTemplateJson.ToJsonString());
|
||||
if (flowTemplateJsonEntity.IsNullOrEmpty())
|
||||
{
|
||||
Id = SnowflakeIdHelper.NextId(),
|
||||
FlowId = flowTemplateJsonEntity.Id,
|
||||
FormId = item
|
||||
};
|
||||
await _repository.AsSugarClient().Insertable(formRelationEntity).ExecuteReturnEntityAsync();
|
||||
}
|
||||
if (entity.Type == 1)
|
||||
{
|
||||
if (await _repository.AsSugarClient().Queryable<FlowFormEntity>().AnyAsync(x => x.Id == formIdList.FirstOrDefault() && !SqlFunc.IsNullOrEmpty(x.FlowId)))
|
||||
throw Oops.Oh(ErrorCode.WF0043);
|
||||
await _repository.AsSugarClient().Updateable<FlowFormEntity>().SetColumns(x => x.FlowId == flowTemplateJsonEntity.Id).Where(x => x.Id == formIdList.FirstOrDefault()).ExecuteCommandAsync();
|
||||
flowTemplateJsonEntity = new FlowTemplateJsonEntity();
|
||||
flowTemplateJsonEntity.Id = SnowflakeIdHelper.NextId();
|
||||
flowTemplateJsonEntity.TemplateId = entity.Id;
|
||||
flowTemplateJsonEntity.Version = "1";
|
||||
flowTemplateJsonEntity.FlowTemplateJson = item.flowTemplateJson.ToJsonString();
|
||||
flowTemplateJsonEntity.FullName = item.fullName;
|
||||
flowTemplateJsonEntity.SortCode = index++;
|
||||
flowTemplateJsonEntity.VisibleType = visibleList.Count == 0 ? 0 : 1;
|
||||
flowTemplateJsonEntity.GroupId = SnowflakeIdHelper.NextId();
|
||||
foreach (var visible in visibleList)
|
||||
{
|
||||
visible.FlowId = flowTemplateJsonEntity.Id;
|
||||
visible.SortCode = visibleList.IndexOf(visible);
|
||||
visible.Type = "1";
|
||||
}
|
||||
if (visibleList.Count > 0)
|
||||
await _repository.AsSugarClient().Insertable(visibleList).CallEntityMethod(m => m.Creator()).ExecuteCommandAsync();
|
||||
await _repository.AsSugarClient().Insertable(flowTemplateJsonEntity).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
|
||||
groupIdList.Add(flowTemplateJsonEntity.GroupId);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 清空就模板关联表单数据
|
||||
if (entity.Type == 1)
|
||||
{
|
||||
string oldFormId = flowTemplateJsonEntity.FlowTemplateJson.ToObject<FlowTemplateJsonModel>().properties.ToObject<StartProperties>().formId;
|
||||
await _repository.AsSugarClient().Updateable<FlowFormEntity>().SetColumns(x => x.FlowId == null).Where(x => x.Id == oldFormId).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await _repository.AsSugarClient().Deleteable<FlowFormRelationEntity>().Where(x => x.FlowId == entity.Id).ExecuteCommandAsync();
|
||||
}
|
||||
if (!groupIdList.Contains(flowTemplateJsonEntity.GroupId))
|
||||
{
|
||||
groupIdList.Add(flowTemplateJsonEntity.GroupId);
|
||||
}
|
||||
var isCreate = flowTemplateJsonEntity.FlowTemplateJson.Equals(item.flowTemplateJson.ToJsonString());//流程json是否变更
|
||||
flowTemplateJsonEntity.FlowTemplateJson = item.flowTemplateJson.ToJsonString();
|
||||
flowTemplateJsonEntity.SortCode = index++;
|
||||
flowTemplateJsonEntity.FullName = item.fullName;
|
||||
flowTemplateJsonEntity.VisibleType = visibleList.Count == 0 ? 0 : 1;
|
||||
if ((await _flowTaskRepository.AnyFlowTask(x => x.DeleteMark == null && x.FlowId == flowTemplateJsonEntity.Id)) && !isCreate)
|
||||
{
|
||||
flag = true;
|
||||
await _repository.AsSugarClient().Updateable(flowTemplateJsonEntity).UpdateColumns(it => new { it.FullName, it.SortCode }).ExecuteCommandHasChangeAsync();
|
||||
flowTemplateJsonEntity.Version = ((await _repository.AsSugarClient().Queryable<FlowTemplateJsonEntity>().Where(x => x.TemplateId == entity.Id && x.FullName == item.fullName).Select(x => SqlFunc.AggregateMax(SqlFunc.ToInt64(x.Version))).FirstAsync()).ParseToInt() + 1).ToString();
|
||||
flowTemplateJsonEntity.Id = SnowflakeIdHelper.NextId();
|
||||
flowTemplateJsonEntity.EnabledMark = 0;
|
||||
flowTemplateJsonEntity.LastModifyTime = null;
|
||||
flowTemplateJsonEntity.LastModifyUserId = null;
|
||||
await _repository.AsSugarClient().Insertable(flowTemplateJsonEntity).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
|
||||
isMainVersionId.Add(flowTemplateJsonEntity.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
await _repository.AsSugarClient().Updateable(flowTemplateJsonEntity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandHasChangeAsync();
|
||||
await _repository.AsSugarClient().Deleteable<FlowEngineVisibleEntity>(a => a.FlowId == flowTemplateJsonEntity.Id).ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
}
|
||||
foreach (var visible in visibleList)
|
||||
{
|
||||
visible.FlowId = flowTemplateJsonEntity.Id;
|
||||
visible.SortCode = visibleList.IndexOf(visible);
|
||||
visible.Type = "1";
|
||||
}
|
||||
if (visibleList.Count > 0)
|
||||
await _repository.AsSugarClient().Insertable(visibleList).CallEntityMethod(m => m.Creator()).ExecuteCommandAsync();
|
||||
if (entity.Type == 1)
|
||||
{
|
||||
var formId = item.flowTemplateJson.properties.ToObject<StartProperties>()?.formId;
|
||||
if (formIdList.Any() && !formIdList.Contains(formId))
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.WF0043);
|
||||
}
|
||||
else
|
||||
{
|
||||
formIdList.Add(formId);
|
||||
}
|
||||
if ((await _repository.AsSugarClient().Queryable<FlowFormEntity>().AnyAsync(x => x.Id == formId && x.FlowId != entity.Id && !SqlFunc.IsNullOrEmpty(x.FlowId))) && formId != onlineFormId)
|
||||
throw Oops.Oh(ErrorCode.WF0043);
|
||||
await _repository.AsSugarClient().Updateable<FlowFormEntity>().SetColumns(x => x.FlowId == entity.Id).Where(x => x.Id == formId).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 发起流程表单id
|
||||
var launchFormIdList = new List<string>();
|
||||
GetFormIdList(item.flowTemplateJson, launchFormIdList);
|
||||
foreach (var launchFormId in launchFormIdList)
|
||||
{
|
||||
var formRelationEntity = new FlowFormRelationEntity
|
||||
{
|
||||
Id = SnowflakeIdHelper.NextId(),
|
||||
FlowId = entity.Id,
|
||||
FormId = launchFormId
|
||||
};
|
||||
await _repository.AsSugarClient().Insertable(formRelationEntity).ExecuteReturnEntityAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
// 删除未使用的流程
|
||||
await _repository.AsSugarClient().Deleteable<FlowTemplateJsonEntity>().Where(x => x.TemplateId == entity.Id && !groupIdList.Contains(x.GroupId)).ExecuteCommandAsync();
|
||||
}
|
||||
var isOk = await _repository.AsSugarClient().Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true).CallEntityMethod(m => m.LastModify()).ExecuteCommandHasChangeAsync();
|
||||
_db.CommitTran();
|
||||
return new { isMainVersion = flag, id = flowTemplateJsonEntity.Id };
|
||||
return new { isMainVersion = flag, id = string.Join(",", isMainVersionId) };
|
||||
}
|
||||
catch (AppFriendlyException ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
_db.RollbackTran();
|
||||
throw Oops.Oh(ex.ErrorCode);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -818,7 +1042,7 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
.Select((a, b) => new FlowTemplateTreeOutput
|
||||
{
|
||||
category = a.Category,
|
||||
id = b.Id,
|
||||
id = a.Id,
|
||||
description = a.Description,
|
||||
creatorTime = a.CreatorTime,
|
||||
creatorUser = SqlFunc.Subqueryable<UserEntity>().Where(u => u.Id == a.CreatorUserId).Select(u => SqlFunc.MergeString(u.RealName, "/", u.Account)),
|
||||
@@ -871,7 +1095,7 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
/// <param name="formIdList"></param>
|
||||
private void GetFormIdList(FlowTemplateJsonModel template, List<string> formIdList)
|
||||
{
|
||||
if (template.IsNotEmptyOrNull()&&!template.type.Equals("subFlow"))
|
||||
if (template.IsNotEmptyOrNull() && !template.type.Equals("subFlow") && !template.type.Equals("timer"))
|
||||
{
|
||||
if (template.properties["formId"].ToString().IsNotEmptyOrNull())
|
||||
{
|
||||
@@ -884,4 +1108,4 @@ public class FlowTemplateService : IFlowTemplateService, IDynamicApiController,
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user