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#

11 months ago
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;
11 months ago
using Mapster;
using Newtonsoft.Json.Linq;
11 months ago
namespace DS.WMS.Core.Flow.Method;
11 months ago
/// <summary>
/// 工作流模板
11 months ago
/// </summary>
public class FlowTemplateService : ServiceBase, IFlowTemplateService
11 months ago
{
/// <summary>
/// 初始化
11 months ago
/// </summary>
/// <param name="serviceProvider"></param>
public FlowTemplateService(IServiceProvider serviceProvider) : base(serviceProvider)
11 months ago
{
}
11 months ago
public DataResult<List<FlowTemplateRes>> GetListByPage(PageRequest request)
{
//序列化查询条件
var whereList = request.GetConditionalModels(Db);
var data = Db.Queryable<FlowTemplate>()
11 months ago
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
11 months ago
.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;
}
11 months ago
public DataResult EditFlowTemplate(FlowTemplateReq req)
{
if (req.Id == 0)
{
var isExist = Db.Queryable<FlowTemplate>().Where(x => x.Name == req.Name).First();
11 months ago
if (isExist != null)
return DataResult.Failed("流程模板名称已存在!");
var data = req.Adapt<FlowTemplate>();
data.Content = EnsureJsonCorrect(data.Content);
var entity = Db.Insertable(data).ExecuteReturnEntity();
11 months ago
return DataResult.Successed("添加成功!", entity.Id);
}
else
{
var info = Db.Queryable<FlowTemplate>().Where(x => x.Id == req.Id).First();
11 months ago
info = req.Adapt(info);
info.Content = EnsureJsonCorrect(info.Content);
Db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
11 months ago
return DataResult.Successed("更新成功!");
}
}
public DataResult<FlowTemplateRes> GetFlowTemplateInfo(string id)
{
var data = Db.Queryable<FlowTemplate>()
11 months ago
// .LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
11 months ago
.Where(a => a.Id == long.Parse(id))
.Select<FlowTemplateRes>()
.First();
return DataResult<FlowTemplateRes>.Success(data);
}
}