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#

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