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.
81 lines
2.8 KiB
C#
81 lines
2.8 KiB
C#
using DS.Module.Core;
|
|
using DS.Module.Core.Extensions;
|
|
using DS.Module.UserModule;
|
|
using DS.WMS.Core.Flow.Dtos;
|
|
using DS.WMS.Core.Flow.Entity;
|
|
using DS.WMS.Core.Flow.Interface;
|
|
using DS.WMS.Core.System.Entity;
|
|
using DS.WMS.Core.System.Interface;
|
|
using Mapster;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using SqlSugar;
|
|
|
|
namespace DS.WMS.Core.Flow.Method;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class FlowInstanceService:IFlowInstanceService
|
|
{
|
|
private readonly IServiceProvider _serviceProvider;
|
|
private readonly ISqlSugarClient db;
|
|
private readonly IUser user;
|
|
private readonly ICommonService _commonService;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="serviceProvider"></param>
|
|
public FlowInstanceService(IServiceProvider serviceProvider)
|
|
{
|
|
_serviceProvider = serviceProvider;
|
|
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
user = _serviceProvider.GetRequiredService<IUser>();
|
|
_commonService = _serviceProvider.GetRequiredService<ICommonService>();
|
|
}
|
|
public DataResult<List<FlowInstanceRes>> GetListByPage(PageRequest request)
|
|
{
|
|
//序列化查询条件
|
|
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
var data = db.Queryable<FlowInstance>().Where(a=>(a.MakerList == "1" || a.MakerList.Contains(user.UserId)) )
|
|
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
|
|
.Select<FlowInstanceRes>()
|
|
.Where(whereList).ToQueryPage(request.PageCondition);
|
|
return data;
|
|
}
|
|
|
|
public DataResult EditFlowInstance(FlowInstanceReq req)
|
|
{
|
|
if (req.Id == 0)
|
|
{
|
|
var isExist = db.Queryable<FlowInstance>().Where(x => x.CustomName == req.CustomName).First();
|
|
if (isExist != null)
|
|
{
|
|
return DataResult.Failed("流程模板名称已存在!");
|
|
}
|
|
|
|
var data = req.Adapt<FlowInstance>();
|
|
|
|
var entity = db.Insertable(data).ExecuteReturnEntity();
|
|
|
|
return DataResult.Successed("添加成功!", entity.Id);
|
|
}
|
|
else
|
|
{
|
|
var info = db.Queryable<FlowInstance>().Where(x => x.Id == req.Id).First();
|
|
|
|
info = req.Adapt(info);
|
|
|
|
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|
return DataResult.Successed("更新成功!");
|
|
}
|
|
}
|
|
|
|
public DataResult<FlowInstanceRes> GetFlowInstanceInfo(string id)
|
|
{
|
|
var data = db.Queryable<FlowInstance>()
|
|
// .LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
|
|
.Where(a => a.Id == long.Parse(id))
|
|
.Select<FlowInstanceRes>()
|
|
.First();
|
|
return DataResult<FlowInstanceRes>.Success(data);
|
|
}
|
|
} |