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.

114 lines
4.1 KiB
C#

10 months ago
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 ClientFlowTemplateService : IClientFlowTemplateService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ICommonService _commonService;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public ClientFlowTemplateService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
_commonService = _serviceProvider.GetRequiredService<ICommonService>();
}
public DataResult<List<FlowTemplateRes>> GetListByPage(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<FlowTemplateTenant>()
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
.Select<FlowTemplateRes>()
.Where(whereList).ToQueryPage(request.PageCondition);
return data;
}
public DataResult EditClientFlowTemplate(FlowTemplateReq req)
{
if (req.Id == 0)
{
return DataResult.Failed("非法请求!",MultiLanguageConst.IllegalRequest);
10 months ago
}
else
{
var info = db.Queryable<FlowTemplateTenant>().Where(x => x.Id == req.Id).First();
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
10 months ago
}
}
public DataResult<FlowTemplateRes> GetClientFlowTemplateInfo(string id)
{
var data = db.Queryable<FlowTemplateTenant>()
.Where(a => a.Id == long.Parse(id))
.Select<FlowTemplateRes>()
.First();
return DataResult<FlowTemplateRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
10 months ago
}
public DataResult ImportFlowTemplate(string id)
{
var info = db.Queryable<FlowTemplate>().Where(x => x.Id == long.Parse(id)).First();
if (info == null)
{
return DataResult.Failed("流程模板不存在!",MultiLanguageConst.FlowTemplateImportNotExist);
10 months ago
}
var data = info.Adapt<FlowTemplateTenant>();
db.Insertable(data).ExecuteCommand();
return DataResult.Successed("引入成功!",MultiLanguageConst.DataImportSuccess);
}
public DataResult DelFlowTemplate(string id)
{
var info = db.Queryable<FlowTemplateTenant>().Where(x => x.Id == long.Parse(id)).First();
if (info == null)
{
return DataResult.Failed("流程模板不存在!",MultiLanguageConst.FlowTemplateNotExist);
}
if (db.Queryable<FlowInstance>().Where(x=>x.TemplateId == long.Parse(id)).Any())
{
return DataResult.Failed("工作流实例存在引用的流程模板不能删除!",MultiLanguageConst.FlowTemplateDelExistImport);
}
db.Deleteable(info).ExecuteCommand();
return DataResult.Successed("删除成功!",MultiLanguageConst.DataDelSuccess);
10 months ago
}
public DataResult<List<FlowTemplateRes>> GetFlowTemplateList(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<FlowTemplate>().Where(a=>a.Status == StatusEnum.Enable)
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
10 months ago
.Select<FlowTemplateRes>()
.Where(whereList).ToQueryPage(request.PageCondition);
return data;
}
}