diff --git a/ds-wms-service/DS.Module.Core/Condition/ConditionContent.cs b/ds-wms-service/DS.Module.Core/Condition/ConditionContent.cs
index 036e4e94..50be4828 100644
--- a/ds-wms-service/DS.Module.Core/Condition/ConditionContent.cs
+++ b/ds-wms-service/DS.Module.Core/Condition/ConditionContent.cs
@@ -8,9 +8,9 @@
public string LogicalOperator { get; set; } = "and";
///
- /// 条件组
+ /// 条件
///
- public List Conditions { get; set; }
+ public List Conditions { get; set; } = [];
///
/// 条件组
@@ -21,6 +21,11 @@
/// 数据源名称
///
public string? SourceName { get; set; }
+
+ ///
+ /// 附加数据项
+ ///
+ public object? ExtraData { get; set; }
}
public class ConditionDetail
diff --git a/ds-wms-service/DS.WMS.Core/Fee/Entity/FeeCustTemplate.cs b/ds-wms-service/DS.WMS.Core/Fee/Entity/FeeCustTemplate.cs
new file mode 100644
index 00000000..8100b98a
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Fee/Entity/FeeCustTemplate.cs
@@ -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
+{
+ ///
+ /// 往来单位费用模板
+ ///
+ [SugarTable("fee_cust_template", "往来单位费用模板")]
+ public class FeeCustTemplate : SharedOrgModel
+ {
+ ///
+ /// 业务类型
+ ///
+ [SugarColumn(ColumnDescription = "业务类型")]
+ public BusinessType BusinessType { get; set; }
+
+ ///
+ /// 业务类型文本
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string BusinessTypeText => BusinessType.GetDescription();
+
+ ///
+ /// 费用类型
+ ///
+ [SugarColumn(ColumnDescription = "费用类型")]
+ public FeeType FeeType { get; set; }
+
+ ///
+ /// 费用类型文本
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string FeeTypeText => FeeType.GetDescription();
+
+ ///
+ /// 名称
+ ///
+ [SugarColumn(ColumnDescription = "名称", Length = 50, IsNullable = false)]
+ public string Name { get; set; } = string.Empty;
+
+ ///
+ /// 说明
+ ///
+ [SugarColumn(ColumnDescription = "说明", Length = 200, IsNullable = true)]
+ public string? Description { get; set; }
+
+ ///
+ /// 判定条件
+ ///
+ [SugarColumn(ColumnDescription = "判定条件", IsNullable = true)]
+ public string? Condition { get; set; }
+
+ ///
+ /// 模板明细
+ ///
+ [Navigate(NavigateType.OneToMany, nameof(FeeCustTemplateDetail.TemplateId))]
+ public List Details { get; set; } = [];
+ }
+}
diff --git a/ds-wms-service/DS.WMS.Core/Fee/Entity/FeeCustTemplateDetail.cs b/ds-wms-service/DS.WMS.Core/Fee/Entity/FeeCustTemplateDetail.cs
index 6d07a0bf..94148455 100644
--- a/ds-wms-service/DS.WMS.Core/Fee/Entity/FeeCustTemplateDetail.cs
+++ b/ds-wms-service/DS.WMS.Core/Fee/Entity/FeeCustTemplateDetail.cs
@@ -1,15 +1,29 @@
using DS.Module.Core;
-using DS.Module.Core.Data;
using SqlSugar;
namespace DS.WMS.Core.Fee.Entity
{
///
- /// 往来单位固定费用
+ /// 往来单位费用模板明细
///
- [SugarTable("fee_cust_template_detail", "往来单位固定费用")]
- public class FeeCustTemplateDetail : BaseModelV2
+ [SugarTable("fee_cust_template_detail", "往来单位费用模板明细")]
+ public class FeeCustTemplateDetail
{
+ ///
+ /// 模板ID
+ ///
+ [SugarColumn(ColumnDescription = "模板ID", IsNullable = false)]
+ public long TemplateId { get; set; }
+ ///
+ /// 所属模板
+ ///
+ [Navigate(NavigateType.OneToOne, nameof(TemplateId))]
+ public FeeCustTemplate? Template { get; set; }
+ ///
+ /// 主键ID
+ ///
+ [SugarColumn(IsPrimaryKey = true)]
+ public long Id { get; set; }
///
/// 费用Id
///
@@ -19,17 +33,22 @@ namespace DS.WMS.Core.Fee.Entity
/// 费用代码 录入费用是作为检索
///
[SugarColumn(ColumnDescription = "费用代码", Length = 50, IsNullable = true)]
- public string FeeCode { get; set; }
+ public string? FeeCode { get; set; }
///
/// 费用名称
///
[SugarColumn(ColumnDescription = "费用名称", Length = 100, IsNullable = true)]
- public string FeeName { get; set; }
+ public string? FeeName { get; set; }
+ ///
+ /// 结算对象Id
+ ///
+ [SugarColumn(ColumnDescription = "结算对象Id")]
+ public long CustomerId { get; set; }
///
/// 结算对象
///
[SugarColumn(ColumnDescription = "结算对象", Length = 100, IsNullable = true)]
- public string CustomerName { get; set; }
+ public string? CustomerName { get; set; }
///
/// 客户类型
///
@@ -39,28 +58,22 @@ namespace DS.WMS.Core.Fee.Entity
/// 收付类型(收、付)
///
[SugarColumn(ColumnDescription = "收付类型(收、付)", IsNullable = false, DefaultValue = "1")]
- public int FeeType { get; set; }
- ///
- /// 客户Id
- ///
- [SugarColumn(ColumnDescription = "客户Id")]
- public long CustomerId { get; set; }
+ public FeeType FeeType { get; set; }
///
/// 费用标准
///
[SugarColumn(ColumnDescription = "费用标准", Length = 20, IsNullable = true)]
- public string Unit { get; set; }
-
+ public string? Unit { get; set; }
///
/// 是否箱型
///
[SugarColumn(ColumnDescription = "是否箱型", DefaultValue = "0")]
- public bool? IsCtn { get; set; } = false;
+ public bool IsCtn { get; set; }
///
/// 币别
///
[SugarColumn(ColumnDescription = "币别", Length = 100, IsNullable = true)]
- public string Currency { get; set; }
+ public string? Currency { get; set; }
///
/// 单价
///
@@ -70,8 +83,7 @@ namespace DS.WMS.Core.Fee.Entity
/// 排序
///
[SugarColumn(ColumnDescription = "排序")]
- public int? OrderNo { get; set; } = 100;
-
+ public int OrderNo { get; set; } = 100;
///
/// 汇率
///
@@ -101,13 +113,21 @@ namespace DS.WMS.Core.Fee.Entity
/// 是否开票
///
[SugarColumn(ColumnDescription = "是否开票", DefaultValue = "0")]
- public bool? IsInvoice { get; set; } = false;
-
+ public bool IsInvoice { get; set; }
///
/// 是否垫付费用
///
[SugarColumn(ColumnDescription = "是否垫付费用", DefaultValue = "0")]
- public bool? IsAdvancedPay { get; set; } = false;
-
+ public bool IsAdvancedPay { get; set; }
+ ///
+ /// 创建时间
+ ///
+ [SugarColumn(ColumnDescription = "创建时间", IsNullable = false)]
+ public DateTime CreateTime { get; set; }
+ ///
+ /// 创建人
+ ///
+ [SugarColumn(ColumnDescription = "创建人", IsNullable = false)]
+ public long CreateBy { get; set; }
}
}
diff --git a/ds-wms-service/DS.WMS.Core/Fee/Entity/FeeRecord.cs b/ds-wms-service/DS.WMS.Core/Fee/Entity/FeeRecord.cs
index d971a31c..34fd7834 100644
--- a/ds-wms-service/DS.WMS.Core/Fee/Entity/FeeRecord.cs
+++ b/ds-wms-service/DS.WMS.Core/Fee/Entity/FeeRecord.cs
@@ -96,7 +96,7 @@ namespace DS.WMS.Core.Fee.Entity
/// 费用标准
///
[SugarColumn(ColumnDescription = "费用标准", Length = 20, IsNullable = true)]
- public string Unit { get; set; }
+ public string? Unit { get; set; }
///
/// 费用标准文本
///
@@ -323,7 +323,7 @@ namespace DS.WMS.Core.Fee.Entity
/// 本位币
///
[SugarColumn(ColumnDescription = "本位币", IsNullable = true, Length = 30)]
- public string LocalCurrency { get; set; } = "CNY";
+ public string? LocalCurrency { get; set; }
///
/// 责任人
diff --git a/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateDetailService.cs b/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateDetailService.cs
index 1f4902e1..a3a8a954 100644
--- a/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateDetailService.cs
+++ b/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateDetailService.cs
@@ -4,6 +4,9 @@ using DS.WMS.Core.Fee.Dtos;
namespace DS.WMS.Core.Fee.Interface;
+///
+/// 往来单位费用模板明细
+///
public interface IFeeCustTemplateDetailService
{
///
@@ -12,14 +15,13 @@ public interface IFeeCustTemplateDetailService
///
///
DataResult> GetListByPage(PageRequest request);
-
-
+
///
/// 编辑
///
///
///
- DataResult EditFeeCustTemplateDetail(FeeCustTemplateDetailReq model);
+ Task EditAsync(FeeCustTemplateDetailReq model);
///
/// 获取详情
diff --git a/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateService.cs b/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateService.cs
new file mode 100644
index 00000000..677ac2eb
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateService.cs
@@ -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
+{
+ ///
+ /// 往来单位费用模板
+ ///
+ public interface IFeeCustTemplateService
+ {
+ ///
+ /// 根据业务ID与类型生成费用
+ ///
+ /// 业务ID
+ /// 业务类型
+ ///
+ Task GenerateFeesAsync(long bsId, BusinessType businessType = BusinessType.OceanShippingExport);
+
+ ///
+ /// 列表
+ ///
+ ///
+ ///
+ Task>> GetListAsync(PageRequest request);
+
+ ///
+ /// 详情
+ ///
+ ///
+ ///
+ Task> GetAsync(long id);
+
+ ///
+ /// 编辑
+ ///
+ ///
+ ///
+ Task EditAsync(FeeCustTemplate model);
+
+ ///
+ /// 根据ID批量删除
+ ///
+ ///
+ ///
+ Task DeleteAsync(IdModel model);
+ }
+}
diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateDetailService.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateDetailService.cs
index f3859a3e..456e0bd1 100644
--- a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateDetailService.cs
+++ b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateDetailService.cs
@@ -9,7 +9,7 @@ using Mapster;
namespace DS.WMS.Core.Fee.Method
{
///
- /// 往来单位固定费用
+ /// 往来单位费用模板明细
///
public class FeeCustTemplateDetailService : FeeServiceBase, IFeeCustTemplateDetailService
{
@@ -30,8 +30,7 @@ namespace DS.WMS.Core.Fee.Method
{
//序列化查询条件
var whereList = request.GetConditionalModels(Db);
- var data = TenantDb.Queryable()
- .Where(whereList)
+ var data = TenantDb.Queryable().Where(whereList)
.Select().ToQueryPage(request.PageCondition);
return data;
}
@@ -41,29 +40,24 @@ namespace DS.WMS.Core.Fee.Method
///
///
///
- public DataResult EditFeeCustTemplateDetail(FeeCustTemplateDetailReq req)
+ public async Task EditAsync(FeeCustTemplateDetailReq req)
{
if (req.Id == 0)
{
- if (TenantDb.Queryable()
- .Where(x => x.FeeId == req.FeeId && x.CustomerId == req.CustomerId && x.FeeType == req.FeeType).Any())
- {
+ if (TenantDb.Queryable().Where(x =>
+ x.FeeId == req.FeeId && x.CustomerId == req.CustomerId && x.FeeType == req.FeeType).Any())
return DataResult.Failed("往来单位固定费用已存在!", MultiLanguageConst.FeeCustTemplateDetailExist);
- }
var data = req.Adapt();
- var entity = TenantDb.Insertable(data).ExecuteReturnEntity();
-
+ var entity = await TenantDb.Insertable(data).ExecuteReturnEntityAsync();
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
}
else
{
var info = TenantDb.Queryable().Where(x => x.Id == req.Id).First();
-
info = req.Adapt(info);
-
- TenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
+ await TenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
}
}
diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateService.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateService.cs
new file mode 100644
index 00000000..8b5558b1
--- /dev/null
+++ b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateService.cs
@@ -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
+{
+ ///
+ /// 往来单位费用模板
+ ///
+ public class FeeCustTemplateService : FeeServiceBase
+ {
+ Lazy actionService;
+ Lazy feeService;
+
+ ///
+ /// 初始化
+ ///
+ ///
+ public FeeCustTemplateService(IServiceProvider serviceProvider) : base(serviceProvider)
+ {
+ actionService = new Lazy(serviceProvider.GetRequiredService());
+ feeService = new Lazy(serviceProvider.GetRequiredService());
+ }
+
+ ///
+ /// 根据业务ID与类型生成费用
+ ///
+ /// 业务ID
+ /// 业务类型
+ ///
+ public async Task GenerateFeesAsync(long bsId, BusinessType businessType = BusinessType.OceanShippingExport)
+ {
+ var list = await TenantDb.Queryable().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(x.Condition)
+ }).ToList();
+ var data = actionService.Value.GetBusinessDataAsync(bsId, businessType, conditionModels.Select(x => x.ConditionModel));
+ if (data == null)
+ return;
+
+ List 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);
+ }
+ }
+ }
+
+ ///
+ /// 列表
+ ///
+ ///
+ ///
+ public async Task>> GetListAsync(PageRequest request)
+ {
+ var whereList = request.GetConditionalModels(Db);
+ return await TenantDb.Queryable().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);
+ }
+
+ ///
+ /// 详情
+ ///
+ ///
+ ///
+ public async Task> GetAsync(long id)
+ {
+ var data = await TenantDb.Queryable().Where(x => x.Id == id)
+ .Includes(x => x.Details).FirstAsync();
+ return DataResult.Success(data, MultiLanguageConst.DataQuerySuccess);
+ }
+
+ ///
+ /// 编辑
+ ///
+ ///
+ ///
+ public async Task 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);
+ }
+
+ ///
+ /// 根据ID批量删除
+ ///
+ ///
+ ///
+ public async Task DeleteAsync(IdModel model)
+ {
+ bool flag = await TenantDb.DeleteNav(x => model.Ids.Contains(x.Id))
+ .Include(x => x.Details).ExecuteCommandAsync();
+ return flag ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
+ }
+ }
+}
diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs
index 588d8501..35539e06 100644
--- a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs
+++ b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs
@@ -136,10 +136,15 @@ namespace DS.WMS.Core.Fee.Method
///
public async Task SaveAsync(IEnumerable items)
{
+ ArgumentNullException.ThrowIfNull(items, nameof(items));
+
var first = items.Select(x => new { x.BusinessType, x.BusinessId }).FirstOrDefault();
if (await IsFeeLockedAsync(first.BusinessId, first.BusinessType))
return DataResult.Failed(MultiLanguageConst.FeeLocked);
+ foreach (var item in items)
+ item.SetTax();
+
DateTime dtNow = DateTime.Now;
await TenantDb.Ado.BeginTranAsync();
try
@@ -169,13 +174,14 @@ namespace DS.WMS.Core.Fee.Method
return DataResult.Failed(sb.ToString(), MultiLanguageConst.Operation_Failed);
}
+ var localCurrency = await Db.Queryable().Where(x => x.Id == User.OrgId).Select(x => x.LocalCurrency).FirstAsync();
foreach (var item in items)
{
if (string.IsNullOrEmpty(item.LocalCurrency))
{
- //默认本位币为CNY
+ //默认本位币为机构本位币或CNY
if (item.Id == 0)
- item.LocalCurrency = RMB_CODE;
+ item.LocalCurrency = localCurrency ?? RMB_CODE;
else
item.LocalCurrency = fees?.Find(x => x.Id == item.Id)?.LocalCurrency;
}
diff --git a/ds-wms-service/DS.WMS.Core/Op/Interface/TaskInteraction/IActionManagerService.cs b/ds-wms-service/DS.WMS.Core/Op/Interface/TaskInteraction/IActionManagerService.cs
index 98057bab..ad23b09a 100644
--- a/ds-wms-service/DS.WMS.Core/Op/Interface/TaskInteraction/IActionManagerService.cs
+++ b/ds-wms-service/DS.WMS.Core/Op/Interface/TaskInteraction/IActionManagerService.cs
@@ -1,7 +1,6 @@
using DS.Module.Core;
using DS.Module.Core.Condition;
using DS.Module.Core.Data;
-using DS.WMS.Core.Op.Dtos.TaskInteraction;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Op.Entity.TaskInteraction;
@@ -15,10 +14,19 @@ namespace DS.WMS.Core.Op.Interface.TaskInteraction
///
/// 根据指定条件返回是否匹配的结果
///
- /// 任务请求
+ /// 要对比的数据源
+ /// 匹配条件
+ ///
+ bool IsMatch(object source, ConditionContent condition);
+
+ ///
+ /// 根据指定条件返回是否匹配的结果
+ ///
+ /// 业务ID
+ /// 业务类型
/// 匹配条件
///
- Task IsMatchAsync(TaskRequest request, IEnumerable conditions);
+ Task IsMatchAsync(long bsId, BusinessType businessType, IEnumerable conditions);
///
/// 获取所需业务数据
@@ -45,22 +53,6 @@ namespace DS.WMS.Core.Op.Interface.TaskInteraction
///
Task ExecuteAsync(TaskFlowDataContext dataContext);
- ///
- /// 触发任务执行动作
- ///
- ///
- ///
- Task TriggerActionAsync(TaskFlowDataContext dataContext);
-
- ///
- /// 触发任务执行动作
- ///
- /// 业务ID
- /// 业务类型
- /// 任务类型
- ///
- Task TriggerActionAsync(long businessId, BusinessType businessType, TaskBaseTypeEnum taskType);
-
///
/// 触发任务执行动作
///
diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionManagerService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionManagerService.cs
index f185a7ae..1fd18f0d 100644
--- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionManagerService.cs
+++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/ActionManagerService.cs
@@ -13,6 +13,7 @@ using Fasterflect;
using Masuit.Tools;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
+using static AnyDiff.DifferenceLines;
namespace DS.WMS.Core.Op.Method.TaskInteraction
{
@@ -35,38 +36,38 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
///
/// 根据指定条件返回是否匹配的结果
///
- /// 任务请求
+ /// 要对比的数据源
+ /// 匹配条件
+ ///
+ 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);
+ }
+
+ ///
+ /// 根据指定条件返回是否匹配的结果
+ ///
+ /// 业务ID
+ /// 业务类型
/// 匹配条件
///
- public async Task IsMatchAsync(TaskRequest request, IEnumerable conditions)
+ public async Task IsMatchAsync(long bsId, BusinessType businessType, IEnumerable conditions)
{
- ArgumentNullException.ThrowIfNull(request, nameof(request));
ArgumentNullException.ThrowIfNull(conditions, nameof(conditions));
- var biz = await GetBusinessDataAsync(request.BusinessId, request.BusinessType, conditions);
+ var biz = await GetBusinessDataAsync(bsId, businessType, conditions);
if (biz != null)
{
- TaskFlowDataContext dataContext = new(
- (TaskFlowDataNameConst.Business, biz)
- );
+ TaskFlowDataContext dataContext = new((TaskFlowDataNameConst.Business, biz));
//循环匹配
foreach (var item in conditions)
{
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;
- }
}
}
@@ -134,53 +135,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
return biz;
}
- ///
- /// 触发任务执行动作
- ///
- ///
- ///
- public async Task TriggerActionAsync(TaskFlowDataContext dataContext)
- {
- ArgumentNullException.ThrowIfNull(dataContext, nameof(dataContext));
-
- long businessId = dataContext.GetOrDefault(TaskFlowDataNameConst.BusinessId);
- BusinessType businessType = BusinessType.OceanShippingExport;
- if (dataContext.TryGetValue(nameof(businessType), out object? value) && value != null)
- {
- if (value is string strValue)
- businessType = Enum.Parse(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(strValue);
- else
- taskType = (TaskBaseTypeEnum)Convert.ChangeType(value2, typeof(TaskBaseTypeEnum));
- }
-
- await TriggerActionAsync(businessId, businessType, taskType);
- }
-
- ///
- /// 触发任务执行动作
- ///
- /// 业务ID
- /// 业务类型
- /// 任务类型
- ///
- public async Task TriggerActionAsync(long businessId, BusinessType businessType, TaskBaseTypeEnum taskType)
- {
- var businessTask = await TenantDb.Queryable().Where(
- x => x.BusinessId == businessId && x.BusinessType == businessType && x.TaskType == taskType).FirstAsync();
-
- if (businessTask != null)
- await TriggerActionAsync(businessTask);
- }
-
///
/// 执行放舱任务(任务台使用)
///
diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs
index bd770d20..9d7499ff 100644
--- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs
+++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskService.cs
@@ -3,6 +3,7 @@ using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Helpers;
using DS.Module.DjyRulesEngine;
+using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Flow.Entity;
using DS.WMS.Core.Flow.Interface;
@@ -76,10 +77,15 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
protected IClientParamService ClientParamService { get; private set; }
///
- /// 规则引擎服务
+ /// 规则库服务
///
protected Lazy RuleEngineService { get; private set; }
+ ///
+ /// 费用模板服务
+ ///
+ protected Lazy FeeTemplateService { get; private set; }
+
///
/// 初始化
///
@@ -95,6 +101,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
FlowService = new Lazy(provider.GetRequiredService());
RuleEngineService = new Lazy(provider.GetRequiredService());
+ FeeTemplateService = new Lazy(provider.GetRequiredService());
+
TenantDb.QueryFilter.Clear();
}
@@ -702,6 +710,13 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
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
diff --git a/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateDetailController.cs b/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateDetailController.cs
index c0ee02bb..d5df86dc 100644
--- a/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateDetailController.cs
+++ b/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateDetailController.cs
@@ -44,7 +44,7 @@ namespace DS.WMS.FeeApi.Controllers
[Route("EditFeeCustTemplateDetail")]
public DataResult EditFeeCustTemplateDetail([FromBody] FeeCustTemplateDetailReq model)
{
- var res = _invokeService.EditFeeCustTemplateDetail(model);
+ var res = _invokeService.EditAsync(model);
return res;
}