You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.6 KiB
C#
85 lines
2.6 KiB
C#
using DS.Module.Core;
|
|
using DS.Module.Core.Extensions;
|
|
using DS.WMS.Core.Flow.Dtos;
|
|
using DS.WMS.Core.Flow.Entity;
|
|
using DS.WMS.Core.Flow.Interface;
|
|
using DS.WMS.Core.Sys.Entity;
|
|
using Mapster;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace DS.WMS.Core.Flow.Method;
|
|
|
|
/// <summary>
|
|
/// 工作流模板
|
|
/// </summary>
|
|
public class FlowTemplateService : ServiceBase, IFlowTemplateService
|
|
{
|
|
/// <summary>
|
|
/// 初始化
|
|
/// </summary>
|
|
/// <param name="serviceProvider"></param>
|
|
public FlowTemplateService(IServiceProvider serviceProvider) : base(serviceProvider)
|
|
{
|
|
}
|
|
|
|
public DataResult<List<FlowTemplateRes>> GetListByPage(PageRequest request)
|
|
{
|
|
//序列化查询条件
|
|
var whereList = request.GetConditionalModels(Db);
|
|
var data = Db.Queryable<FlowTemplate>()
|
|
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
|
|
.Select<FlowTemplateRes>()
|
|
.Where(whereList).ToQueryPage(request.PageCondition);
|
|
return data;
|
|
}
|
|
|
|
static string EnsureJsonCorrect(string json)
|
|
{
|
|
//JObject jsonObj = JObject.Parse(json);
|
|
//var children = jsonObj["child"]["children"] as JArray;
|
|
//if (children != null && children.HasValues)
|
|
//{
|
|
// foreach (var item in children)
|
|
// {
|
|
|
|
// }
|
|
//}
|
|
|
|
//return jsonObj.ToString();
|
|
|
|
return json;
|
|
}
|
|
|
|
public DataResult EditFlowTemplate(FlowTemplateReq req)
|
|
{
|
|
if (req.Id == 0)
|
|
{
|
|
var isExist = Db.Queryable<FlowTemplate>().Where(x => x.Name == req.Name).First();
|
|
if (isExist != null)
|
|
return DataResult.Failed("流程模板名称已存在!");
|
|
|
|
var data = req.Adapt<FlowTemplate>();
|
|
data.Content = EnsureJsonCorrect(data.Content);
|
|
var entity = Db.Insertable(data).ExecuteReturnEntity();
|
|
return DataResult.Successed("添加成功!", entity.Id);
|
|
}
|
|
else
|
|
{
|
|
var info = Db.Queryable<FlowTemplate>().Where(x => x.Id == req.Id).First();
|
|
info = req.Adapt(info);
|
|
info.Content = EnsureJsonCorrect(info.Content);
|
|
Db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|
return DataResult.Successed("更新成功!");
|
|
}
|
|
}
|
|
|
|
public DataResult<FlowTemplateRes> GetFlowTemplateInfo(string id)
|
|
{
|
|
var data = Db.Queryable<FlowTemplate>()
|
|
// .LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
|
|
.Where(a => a.Id == long.Parse(id))
|
|
.Select<FlowTemplateRes>()
|
|
.First();
|
|
return DataResult<FlowTemplateRes>.Success(data);
|
|
}
|
|
} |