费用模板

usertest
嵇文龙 3 months ago
parent 297d131ad1
commit 282f876afc

@ -8,9 +8,9 @@
public string LogicalOperator { get; set; } = "and"; public string LogicalOperator { get; set; } = "and";
/// <summary> /// <summary>
/// 条件 /// 条件
/// </summary> /// </summary>
public List<ConditionDetail> Conditions { get; set; } public List<ConditionDetail> Conditions { get; set; } = [];
/// <summary> /// <summary>
/// 条件组 /// 条件组
@ -21,6 +21,11 @@
/// 数据源名称 /// 数据源名称
/// </summary> /// </summary>
public string? SourceName { get; set; } public string? SourceName { get; set; }
/// <summary>
/// 附加数据项
/// </summary>
public object? ExtraData { get; set; }
} }
public class ConditionDetail public class ConditionDetail

@ -0,0 +1,63 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Op.Entity;
using Masuit.Tools.Systems;
using SqlSugar;
namespace DS.WMS.Core.Fee.Entity
{
/// <summary>
/// 往来单位费用模板
/// </summary>
[SugarTable("fee_cust_template", "往来单位费用模板")]
public class FeeCustTemplate : SharedOrgModel<long>
{
/// <summary>
/// 业务类型
/// </summary>
[SugarColumn(ColumnDescription = "业务类型")]
public BusinessType BusinessType { get; set; }
/// <summary>
/// 业务类型文本
/// </summary>
[SugarColumn(IsIgnore = true)]
public string BusinessTypeText => BusinessType.GetDescription();
/// <summary>
/// 费用类型
/// </summary>
[SugarColumn(ColumnDescription = "费用类型")]
public FeeType FeeType { get; set; }
/// <summary>
/// 费用类型文本
/// </summary>
[SugarColumn(IsIgnore = true)]
public string FeeTypeText => FeeType.GetDescription();
/// <summary>
/// 名称
/// </summary>
[SugarColumn(ColumnDescription = "名称", Length = 50, IsNullable = false)]
public string Name { get; set; } = string.Empty;
/// <summary>
/// 说明
/// </summary>
[SugarColumn(ColumnDescription = "说明", Length = 200, IsNullable = true)]
public string? Description { get; set; }
/// <summary>
/// 判定条件
/// </summary>
[SugarColumn(ColumnDescription = "判定条件", IsNullable = true)]
public string? Condition { get; set; }
/// <summary>
/// 模板明细
/// </summary>
[Navigate(NavigateType.OneToMany, nameof(FeeCustTemplateDetail.TemplateId))]
public List<FeeCustTemplateDetail> Details { get; set; } = [];
}
}

@ -1,15 +1,29 @@
using DS.Module.Core; using DS.Module.Core;
using DS.Module.Core.Data;
using SqlSugar; using SqlSugar;
namespace DS.WMS.Core.Fee.Entity namespace DS.WMS.Core.Fee.Entity
{ {
/// <summary> /// <summary>
/// 往来单位固定费用 /// 往来单位费用模板明细
/// </summary> /// </summary>
[SugarTable("fee_cust_template_detail", "往来单位固定费用")] [SugarTable("fee_cust_template_detail", "往来单位费用模板明细")]
public class FeeCustTemplateDetail : BaseModelV2<long> public class FeeCustTemplateDetail
{ {
/// <summary>
/// 模板ID
/// </summary>
[SugarColumn(ColumnDescription = "模板ID", IsNullable = false)]
public long TemplateId { get; set; }
/// <summary>
/// 所属模板
/// </summary>
[Navigate(NavigateType.OneToOne, nameof(TemplateId))]
public FeeCustTemplate? Template { get; set; }
/// <summary>
/// 主键ID
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
/// <summary> /// <summary>
/// 费用Id /// 费用Id
/// </summary> /// </summary>
@ -19,17 +33,22 @@ namespace DS.WMS.Core.Fee.Entity
/// 费用代码 录入费用是作为检索 /// 费用代码 录入费用是作为检索
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "费用代码", Length = 50, IsNullable = true)] [SugarColumn(ColumnDescription = "费用代码", Length = 50, IsNullable = true)]
public string FeeCode { get; set; } public string? FeeCode { get; set; }
/// <summary> /// <summary>
/// 费用名称 /// 费用名称
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "费用名称", Length = 100, IsNullable = true)] [SugarColumn(ColumnDescription = "费用名称", Length = 100, IsNullable = true)]
public string FeeName { get; set; } public string? FeeName { get; set; }
/// <summary>
/// 结算对象Id
/// </summary>
[SugarColumn(ColumnDescription = "结算对象Id")]
public long CustomerId { get; set; }
/// <summary> /// <summary>
/// 结算对象 /// 结算对象
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "结算对象", Length = 100, IsNullable = true)] [SugarColumn(ColumnDescription = "结算对象", Length = 100, IsNullable = true)]
public string CustomerName { get; set; } public string? CustomerName { get; set; }
/// <summary> /// <summary>
/// 客户类型 /// 客户类型
/// </summary> /// </summary>
@ -39,28 +58,22 @@ namespace DS.WMS.Core.Fee.Entity
/// 收付类型(收、付) /// 收付类型(收、付)
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "收付类型(收、付)", IsNullable = false, DefaultValue = "1")] [SugarColumn(ColumnDescription = "收付类型(收、付)", IsNullable = false, DefaultValue = "1")]
public int FeeType { get; set; } public FeeType FeeType { get; set; }
/// <summary>
/// 客户Id
/// </summary>
[SugarColumn(ColumnDescription = "客户Id")]
public long CustomerId { get; set; }
/// <summary> /// <summary>
/// 费用标准 /// 费用标准
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "费用标准", Length = 20, IsNullable = true)] [SugarColumn(ColumnDescription = "费用标准", Length = 20, IsNullable = true)]
public string Unit { get; set; } public string? Unit { get; set; }
/// <summary> /// <summary>
/// 是否箱型 /// 是否箱型
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "是否箱型", DefaultValue = "0")] [SugarColumn(ColumnDescription = "是否箱型", DefaultValue = "0")]
public bool? IsCtn { get; set; } = false; public bool IsCtn { get; set; }
/// <summary> /// <summary>
/// 币别 /// 币别
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "币别", Length = 100, IsNullable = true)] [SugarColumn(ColumnDescription = "币别", Length = 100, IsNullable = true)]
public string Currency { get; set; } public string? Currency { get; set; }
/// <summary> /// <summary>
/// 单价 /// 单价
/// </summary> /// </summary>
@ -70,8 +83,7 @@ namespace DS.WMS.Core.Fee.Entity
/// 排序 /// 排序
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "排序")] [SugarColumn(ColumnDescription = "排序")]
public int? OrderNo { get; set; } = 100; public int OrderNo { get; set; } = 100;
/// <summary> /// <summary>
/// 汇率 /// 汇率
/// </summary> /// </summary>
@ -101,13 +113,21 @@ namespace DS.WMS.Core.Fee.Entity
/// 是否开票 /// 是否开票
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "是否开票", DefaultValue = "0")] [SugarColumn(ColumnDescription = "是否开票", DefaultValue = "0")]
public bool? IsInvoice { get; set; } = false; public bool IsInvoice { get; set; }
/// <summary> /// <summary>
/// 是否垫付费用 /// 是否垫付费用
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "是否垫付费用", DefaultValue = "0")] [SugarColumn(ColumnDescription = "是否垫付费用", DefaultValue = "0")]
public bool? IsAdvancedPay { get; set; } = false; public bool IsAdvancedPay { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnDescription = "创建时间", IsNullable = false)]
public DateTime CreateTime { get; set; }
/// <summary>
/// 创建人
/// </summary>
[SugarColumn(ColumnDescription = "创建人", IsNullable = false)]
public long CreateBy { get; set; }
} }
} }

@ -96,7 +96,7 @@ namespace DS.WMS.Core.Fee.Entity
/// 费用标准 /// 费用标准
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "费用标准", Length = 20, IsNullable = true)] [SugarColumn(ColumnDescription = "费用标准", Length = 20, IsNullable = true)]
public string Unit { get; set; } public string? Unit { get; set; }
/// <summary> /// <summary>
/// 费用标准文本 /// 费用标准文本
/// </summary> /// </summary>
@ -323,7 +323,7 @@ namespace DS.WMS.Core.Fee.Entity
/// 本位币 /// 本位币
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "本位币", IsNullable = true, Length = 30)] [SugarColumn(ColumnDescription = "本位币", IsNullable = true, Length = 30)]
public string LocalCurrency { get; set; } = "CNY"; public string? LocalCurrency { get; set; }
/// <summary> /// <summary>
/// 责任人 /// 责任人

@ -4,6 +4,9 @@ using DS.WMS.Core.Fee.Dtos;
namespace DS.WMS.Core.Fee.Interface; namespace DS.WMS.Core.Fee.Interface;
/// <summary>
/// 往来单位费用模板明细
/// </summary>
public interface IFeeCustTemplateDetailService public interface IFeeCustTemplateDetailService
{ {
/// <summary> /// <summary>
@ -13,13 +16,12 @@ public interface IFeeCustTemplateDetailService
/// <returns></returns> /// <returns></returns>
DataResult<List<FeeCustTemplateDetailRes>> GetListByPage(PageRequest request); DataResult<List<FeeCustTemplateDetailRes>> GetListByPage(PageRequest request);
/// <summary> /// <summary>
/// 编辑 /// 编辑
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
/// <returns></returns> /// <returns></returns>
DataResult EditFeeCustTemplateDetail(FeeCustTemplateDetailReq model); Task<DataResult> EditAsync(FeeCustTemplateDetailReq model);
/// <summary> /// <summary>
/// 获取详情 /// 获取详情

@ -0,0 +1,49 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Op.Entity;
namespace DS.WMS.Core.Fee.Interface
{
/// <summary>
/// 往来单位费用模板
/// </summary>
public interface IFeeCustTemplateService
{
/// <summary>
/// 根据业务ID与类型生成费用
/// </summary>
/// <param name="bsId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <returns></returns>
Task GenerateFeesAsync(long bsId, BusinessType businessType = BusinessType.OceanShippingExport);
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Task<DataResult<List<FeeCustTemplate>>> GetListAsync(PageRequest request);
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<DataResult<FeeCustTemplate>> GetAsync(long id);
/// <summary>
/// 编辑
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
Task<DataResult> EditAsync(FeeCustTemplate model);
/// <summary>
/// 根据ID批量删除
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
Task<DataResult> DeleteAsync(IdModel model);
}
}

@ -9,7 +9,7 @@ using Mapster;
namespace DS.WMS.Core.Fee.Method namespace DS.WMS.Core.Fee.Method
{ {
/// <summary> /// <summary>
/// 往来单位固定费用 /// 往来单位费用模板明细
/// </summary> /// </summary>
public class FeeCustTemplateDetailService : FeeServiceBase, IFeeCustTemplateDetailService public class FeeCustTemplateDetailService : FeeServiceBase, IFeeCustTemplateDetailService
{ {
@ -30,8 +30,7 @@ namespace DS.WMS.Core.Fee.Method
{ {
//序列化查询条件 //序列化查询条件
var whereList = request.GetConditionalModels(Db); var whereList = request.GetConditionalModels(Db);
var data = TenantDb.Queryable<FeeCustTemplateDetail>() var data = TenantDb.Queryable<FeeCustTemplateDetail>().Where(whereList)
.Where(whereList)
.Select<FeeCustTemplateDetailRes>().ToQueryPage(request.PageCondition); .Select<FeeCustTemplateDetailRes>().ToQueryPage(request.PageCondition);
return data; return data;
} }
@ -41,29 +40,24 @@ namespace DS.WMS.Core.Fee.Method
/// </summary> /// </summary>
/// <param name="req"></param> /// <param name="req"></param>
/// <returns></returns> /// <returns></returns>
public DataResult EditFeeCustTemplateDetail(FeeCustTemplateDetailReq req) public async Task<DataResult> EditAsync(FeeCustTemplateDetailReq req)
{ {
if (req.Id == 0) if (req.Id == 0)
{ {
if (TenantDb.Queryable<FeeCustTemplateDetail>() if (TenantDb.Queryable<FeeCustTemplateDetail>().Where(x =>
.Where(x => x.FeeId == req.FeeId && x.CustomerId == req.CustomerId && x.FeeType == req.FeeType).Any()) x.FeeId == req.FeeId && x.CustomerId == req.CustomerId && x.FeeType == req.FeeType).Any())
{
return DataResult.Failed("往来单位固定费用已存在!", MultiLanguageConst.FeeCustTemplateDetailExist); return DataResult.Failed("往来单位固定费用已存在!", MultiLanguageConst.FeeCustTemplateDetailExist);
}
var data = req.Adapt<FeeCustTemplateDetail>(); var data = req.Adapt<FeeCustTemplateDetail>();
var entity = TenantDb.Insertable(data).ExecuteReturnEntity(); var entity = await TenantDb.Insertable(data).ExecuteReturnEntityAsync();
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess); return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
} }
else else
{ {
var info = TenantDb.Queryable<FeeCustTemplateDetail>().Where(x => x.Id == req.Id).First(); var info = TenantDb.Queryable<FeeCustTemplateDetail>().Where(x => x.Id == req.Id).First();
info = req.Adapt(info); info = req.Adapt(info);
await TenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
TenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess); return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
} }
} }

@ -0,0 +1,207 @@
using DS.Module.Core;
using DS.Module.Core.Condition;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Op.Interface.TaskInteraction;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using SqlSugar;
namespace DS.WMS.Core.Fee.Method
{
/// <summary>
/// 往来单位费用模板
/// </summary>
public class FeeCustTemplateService : FeeServiceBase
{
Lazy<IActionManagerService> actionService;
Lazy<IFeeRecordService> feeService;
/// <summary>
/// 初始化
/// </summary>
/// <param name="serviceProvider"></param>
public FeeCustTemplateService(IServiceProvider serviceProvider) : base(serviceProvider)
{
actionService = new Lazy<IActionManagerService>(serviceProvider.GetRequiredService<IActionManagerService>());
feeService = new Lazy<IFeeRecordService>(serviceProvider.GetRequiredService<IFeeRecordService>());
}
/// <summary>
/// 根据业务ID与类型生成费用
/// </summary>
/// <param name="bsId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <returns></returns>
public async Task GenerateFeesAsync(long bsId, BusinessType businessType = BusinessType.OceanShippingExport)
{
var list = await TenantDb.Queryable<FeeCustTemplate>().Where(x => x.BusinessType == businessType &&
!SqlFunc.IsNullOrEmpty(x.Condition)).Select(x => new
{
x.Id,
x.FeeType,
x.Condition,
Details = x.Details.Select(y => new
{
y.FeeId,
y.FeeCode,
y.FeeName,
y.FeeType,
y.CustomerId,
y.CustomerName,
y.CustomerType,
y.Unit,
y.IsCtn,
y.Currency,
y.UnitPrice,
y.ExchangeRate,
y.TaxRate,
y.AccTaxRate,
y.Tax,
y.TaxUnitPrice,
y.IsInvoice,
y.IsAdvancedPay
})
}).ToListAsync();
if (list.Count == 0)
return;
var conditionModels = list.Select(x => new
{
x.Id,
ConditionModel = JsonConvert.DeserializeObject<ConditionContent>(x.Condition)
}).ToList();
var data = actionService.Value.GetBusinessDataAsync(bsId, businessType, conditionModels.Select(x => x.ConditionModel));
if (data == null)
return;
List<FeeRecord> feeList = [];
foreach (var item in list)
{
var conditionModel = conditionModels.Find(x => x.Id == item.Id)?.ConditionModel;
if (actionService.Value.IsMatch(data, conditionModel))
{
var fees = item.Details.Select(x => new FeeRecord
{
BusinessId = bsId,
BusinessType = businessType,
FeeType = x.FeeType,
FeeId = x.FeeId,
FeeCode = x.FeeCode,
FeeName = x.FeeName,
CustomerId = x.CustomerId,
CustomerName = x.CustomerName,
CustomerType = x.CustomerType?.ToString(),
Unit = x.Unit,
UnitPrice = x.UnitPrice.GetValueOrDefault(),
Currency = x.Currency,
//IsCtn = x.IsCtn,
ExchangeRate = x.ExchangeRate,
TaxRate = x.TaxRate.GetValueOrDefault(),
AccTaxRate = x.AccTaxRate.GetValueOrDefault(),
Tax = x.Tax.GetValueOrDefault(),
TaxUnitPrice = x.TaxUnitPrice.GetValueOrDefault(),
IsInvoice = x.IsInvoice,
IsAdvancedPay = x.IsAdvancedPay,
Amount = x.UnitPrice.GetValueOrDefault()
});
feeList.AddRange(fees);
}
}
if (feeList.Count > 0)
{
var result = await feeService.Value.SaveAsync(feeList);
if (!result.Succeeded)
{
//记录失败日志
await new ApplicationException(result.Message).LogAsync(Db);
}
}
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public async Task<DataResult<List<FeeCustTemplate>>> GetListAsync(PageRequest request)
{
var whereList = request.GetConditionalModels(Db);
return await TenantDb.Queryable<FeeCustTemplate>().Select(x => new FeeCustTemplate
{
Id = x.Id,
BusinessType = x.BusinessType,
FeeType = x.FeeType,
Name = x.Name,
IsShared = x.IsShared,
Note = x.Note,
CreateBy = x.CreateBy,
CreateTime = x.CreateTime
}).Where(whereList).ToQueryPageAsync(request.PageCondition);
}
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<DataResult<FeeCustTemplate>> GetAsync(long id)
{
var data = await TenantDb.Queryable<FeeCustTemplate>().Where(x => x.Id == id)
.Includes(x => x.Details).FirstAsync();
return DataResult<FeeCustTemplate>.Success(data, MultiLanguageConst.DataQuerySuccess);
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public async Task<DataResult> EditAsync(FeeCustTemplate model)
{
if (model.Details.Count > 0)
{
long userId = long.Parse(User.UserId);
DateTime dt = DateTime.Now;
foreach (var item in model.Details)
{
item.TemplateId = model.Id;
item.CreateBy = userId;
item.CreateTime = dt;
}
}
bool flag;
if (model.Id == 0)
{
flag = await TenantDb.InsertNav(model).Include(x => x.Details).ExecuteCommandAsync();
}
else
{
flag = await TenantDb.Updateable(model).ExecuteCommandAsync() > 0;
flag = await TenantDb.Storageable(model.Details).DefaultAddElseUpdate().ExecuteCommandAsync() > 0;
}
return flag ? DataResult.Successed("添加成功!", model.Id, MultiLanguageConst.DataCreateSuccess)
: DataResult.FailedWithDesc(MultiLanguageConst.Operation_Failed);
}
/// <summary>
/// 根据ID批量删除
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public async Task<DataResult> DeleteAsync(IdModel model)
{
bool flag = await TenantDb.DeleteNav<FeeCustTemplate>(x => model.Ids.Contains(x.Id))
.Include(x => x.Details).ExecuteCommandAsync();
return flag ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}
}

@ -136,10 +136,15 @@ namespace DS.WMS.Core.Fee.Method
/// <returns></returns> /// <returns></returns>
public async Task<DataResult> SaveAsync(IEnumerable<FeeRecord> items) public async Task<DataResult> SaveAsync(IEnumerable<FeeRecord> items)
{ {
ArgumentNullException.ThrowIfNull(items, nameof(items));
var first = items.Select(x => new { x.BusinessType, x.BusinessId }).FirstOrDefault(); var first = items.Select(x => new { x.BusinessType, x.BusinessId }).FirstOrDefault();
if (await IsFeeLockedAsync(first.BusinessId, first.BusinessType)) if (await IsFeeLockedAsync(first.BusinessId, first.BusinessType))
return DataResult.Failed(MultiLanguageConst.FeeLocked); return DataResult.Failed(MultiLanguageConst.FeeLocked);
foreach (var item in items)
item.SetTax();
DateTime dtNow = DateTime.Now; DateTime dtNow = DateTime.Now;
await TenantDb.Ado.BeginTranAsync(); await TenantDb.Ado.BeginTranAsync();
try try
@ -169,13 +174,14 @@ namespace DS.WMS.Core.Fee.Method
return DataResult.Failed(sb.ToString(), MultiLanguageConst.Operation_Failed); return DataResult.Failed(sb.ToString(), MultiLanguageConst.Operation_Failed);
} }
var localCurrency = await Db.Queryable<SysOrg>().Where(x => x.Id == User.OrgId).Select(x => x.LocalCurrency).FirstAsync();
foreach (var item in items) foreach (var item in items)
{ {
if (string.IsNullOrEmpty(item.LocalCurrency)) if (string.IsNullOrEmpty(item.LocalCurrency))
{ {
//默认本位币为CNY //默认本位币为机构本位币或CNY
if (item.Id == 0) if (item.Id == 0)
item.LocalCurrency = RMB_CODE; item.LocalCurrency = localCurrency ?? RMB_CODE;
else else
item.LocalCurrency = fees?.Find(x => x.Id == item.Id)?.LocalCurrency; item.LocalCurrency = fees?.Find(x => x.Id == item.Id)?.LocalCurrency;
} }

@ -1,7 +1,6 @@
using DS.Module.Core; using DS.Module.Core;
using DS.Module.Core.Condition; using DS.Module.Core.Condition;
using DS.Module.Core.Data; using DS.Module.Core.Data;
using DS.WMS.Core.Op.Dtos.TaskInteraction;
using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Op.Entity.TaskInteraction; using DS.WMS.Core.Op.Entity.TaskInteraction;
@ -15,10 +14,19 @@ namespace DS.WMS.Core.Op.Interface.TaskInteraction
/// <summary> /// <summary>
/// 根据指定条件返回是否匹配的结果 /// 根据指定条件返回是否匹配的结果
/// </summary> /// </summary>
/// <param name="request">任务请求</param> /// <param name="source">要对比的数据源</param>
/// <param name="condition">匹配条件</param>
/// <returns></returns>
bool IsMatch(object source, ConditionContent condition);
/// <summary>
/// 根据指定条件返回是否匹配的结果
/// </summary>
/// <param name="bsId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <param name="conditions">匹配条件</param> /// <param name="conditions">匹配条件</param>
/// <returns></returns> /// <returns></returns>
Task<bool> IsMatchAsync(TaskRequest request, IEnumerable<ConditionContent> conditions); Task<bool> IsMatchAsync(long bsId, BusinessType businessType, IEnumerable<ConditionContent> conditions);
/// <summary> /// <summary>
/// 获取所需业务数据 /// 获取所需业务数据
@ -45,22 +53,6 @@ namespace DS.WMS.Core.Op.Interface.TaskInteraction
/// <returns></returns> /// <returns></returns>
Task ExecuteAsync(TaskFlowDataContext dataContext); Task ExecuteAsync(TaskFlowDataContext dataContext);
/// <summary>
/// 触发任务执行动作
/// </summary>
/// <param name="dataContext"></param>
/// <returns></returns>
Task TriggerActionAsync(TaskFlowDataContext dataContext);
/// <summary>
/// 触发任务执行动作
/// </summary>
/// <param name="businessId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <param name="taskType">任务类型</param>
/// <returns></returns>
Task TriggerActionAsync(long businessId, BusinessType businessType, TaskBaseTypeEnum taskType);
/// <summary> /// <summary>
/// 触发任务执行动作 /// 触发任务执行动作
/// </summary> /// </summary>

@ -13,6 +13,7 @@ using Fasterflect;
using Masuit.Tools; using Masuit.Tools;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using SqlSugar; using SqlSugar;
using static AnyDiff.DifferenceLines;
namespace DS.WMS.Core.Op.Method.TaskInteraction namespace DS.WMS.Core.Op.Method.TaskInteraction
{ {
@ -35,38 +36,38 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
/// <summary> /// <summary>
/// 根据指定条件返回是否匹配的结果 /// 根据指定条件返回是否匹配的结果
/// </summary> /// </summary>
/// <param name="request">任务请求</param> /// <param name="source">要对比的数据源</param>
/// <param name="condition">匹配条件</param>
/// <returns></returns>
public bool IsMatch(object source, ConditionContent condition)
{
ArgumentNullException.ThrowIfNull(source, nameof(source));
ArgumentNullException.ThrowIfNull(condition, nameof(condition));
TaskFlowDataContext dataContext = new((TaskFlowDataNameConst.Business, source));
return ConditionHelper.IsPass(condition, dataContext);
}
/// <summary>
/// 根据指定条件返回是否匹配的结果
/// </summary>
/// <param name="bsId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <param name="conditions">匹配条件</param> /// <param name="conditions">匹配条件</param>
/// <returns></returns> /// <returns></returns>
public async Task<bool> IsMatchAsync(TaskRequest request, IEnumerable<ConditionContent> conditions) public async Task<bool> IsMatchAsync(long bsId, BusinessType businessType, IEnumerable<ConditionContent> conditions)
{ {
ArgumentNullException.ThrowIfNull(request, nameof(request));
ArgumentNullException.ThrowIfNull(conditions, nameof(conditions)); ArgumentNullException.ThrowIfNull(conditions, nameof(conditions));
var biz = await GetBusinessDataAsync(request.BusinessId, request.BusinessType, conditions); var biz = await GetBusinessDataAsync(bsId, businessType, conditions);
if (biz != null) if (biz != null)
{ {
TaskFlowDataContext dataContext = new( TaskFlowDataContext dataContext = new((TaskFlowDataNameConst.Business, biz));
(TaskFlowDataNameConst.Business, biz)
);
//循环匹配 //循环匹配
foreach (var item in conditions) foreach (var item in conditions)
{ {
if (ConditionHelper.IsPass(item, dataContext)) if (ConditionHelper.IsPass(item, dataContext))
{
//var logEntity = new BusinessTaskLog
//{
// ActionType = ActionType.Create,
// BusinessId = request.BusinessId,
// BusinessType = request.BusinessType,
// TaskType = request.TaskType,
// CreateBy = long.Parse(User.UserId),
// CreateTime = DateTime.Now,
// Remark = $"符合设定条件,已跳过任务的创建"
//};
//await LogService.WriteLogAsync(logEntity);
return true; return true;
}
} }
} }
@ -134,53 +135,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
return biz; return biz;
} }
/// <summary>
/// 触发任务执行动作
/// </summary>
/// <param name="dataContext"></param>
/// <returns></returns>
public async Task TriggerActionAsync(TaskFlowDataContext dataContext)
{
ArgumentNullException.ThrowIfNull(dataContext, nameof(dataContext));
long businessId = dataContext.GetOrDefault<long>(TaskFlowDataNameConst.BusinessId);
BusinessType businessType = BusinessType.OceanShippingExport;
if (dataContext.TryGetValue(nameof(businessType), out object? value) && value != null)
{
if (value is string strValue)
businessType = Enum.Parse<BusinessType>(strValue);
else
businessType = (BusinessType)Convert.ChangeType(value, typeof(BusinessType));
}
TaskBaseTypeEnum taskType = TaskBaseTypeEnum.WAIT_SPACE_RELEASE;
if (dataContext.TryGetValue(nameof(taskType), out object? value2) && value2 != null)
{
if (value2 is string strValue)
taskType = Enum.Parse<TaskBaseTypeEnum>(strValue);
else
taskType = (TaskBaseTypeEnum)Convert.ChangeType(value2, typeof(TaskBaseTypeEnum));
}
await TriggerActionAsync(businessId, businessType, taskType);
}
/// <summary>
/// 触发任务执行动作
/// </summary>
/// <param name="businessId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <param name="taskType">任务类型</param>
/// <returns></returns>
public async Task TriggerActionAsync(long businessId, BusinessType businessType, TaskBaseTypeEnum taskType)
{
var businessTask = await TenantDb.Queryable<BusinessTask>().Where(
x => x.BusinessId == businessId && x.BusinessType == businessType && x.TaskType == taskType).FirstAsync();
if (businessTask != null)
await TriggerActionAsync(businessTask);
}
/// <summary> /// <summary>
/// 执行放舱任务(任务台使用) /// 执行放舱任务(任务台使用)
/// </summary> /// </summary>

@ -3,6 +3,7 @@ using DS.Module.Core;
using DS.Module.Core.Data; using DS.Module.Core.Data;
using DS.Module.Core.Helpers; using DS.Module.Core.Helpers;
using DS.Module.DjyRulesEngine; using DS.Module.DjyRulesEngine;
using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Flow.Dtos; using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Flow.Entity; using DS.WMS.Core.Flow.Entity;
using DS.WMS.Core.Flow.Interface; using DS.WMS.Core.Flow.Interface;
@ -76,10 +77,15 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
protected IClientParamService ClientParamService { get; private set; } protected IClientParamService ClientParamService { get; private set; }
/// <summary> /// <summary>
/// 规则引擎服务 /// 规则服务
/// </summary> /// </summary>
protected Lazy<IRuleEngineService> RuleEngineService { get; private set; } protected Lazy<IRuleEngineService> RuleEngineService { get; private set; }
/// <summary>
/// 费用模板服务
/// </summary>
protected Lazy<IFeeCustTemplateService> FeeTemplateService { get; private set; }
/// <summary> /// <summary>
/// 初始化 /// 初始化
/// </summary> /// </summary>
@ -95,6 +101,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
FlowService = new Lazy<IClientFlowInstanceService>(provider.GetRequiredService<IClientFlowInstanceService>()); FlowService = new Lazy<IClientFlowInstanceService>(provider.GetRequiredService<IClientFlowInstanceService>());
RuleEngineService = new Lazy<IRuleEngineService>(provider.GetRequiredService<IRuleEngineService>()); RuleEngineService = new Lazy<IRuleEngineService>(provider.GetRequiredService<IRuleEngineService>());
FeeTemplateService = new Lazy<IFeeCustTemplateService>(provider.GetRequiredService<IFeeCustTemplateService>());
TenantDb.QueryFilter.Clear<IOrgId>(); TenantDb.QueryFilter.Clear<IOrgId>();
} }
@ -702,6 +710,13 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
remark += ";驳回理由:" + callback.RejectReason; remark += ";驳回理由:" + callback.RejectReason;
} }
else if (callback.FlowStatus == FlowStatusEnum.Approve)
{
if (taskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT)
{
FeeTemplateService.Value.GenerateFeesAsync(callback.BusinessId, callback.BusinessType.GetValueOrDefault());
}
}
//记录日志 //记录日志
await LogService.WriteLogAsync(new BusinessTaskLog await LogService.WriteLogAsync(new BusinessTaskLog

@ -44,7 +44,7 @@ namespace DS.WMS.FeeApi.Controllers
[Route("EditFeeCustTemplateDetail")] [Route("EditFeeCustTemplateDetail")]
public DataResult EditFeeCustTemplateDetail([FromBody] FeeCustTemplateDetailReq model) public DataResult EditFeeCustTemplateDetail([FromBody] FeeCustTemplateDetailReq model)
{ {
var res = _invokeService.EditFeeCustTemplateDetail(model); var res = _invokeService.EditAsync(model);
return res; return res;
} }

Loading…
Cancel
Save