费用模板

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

@ -8,9 +8,9 @@
public string LogicalOperator { get; set; } = "and";
/// <summary>
/// 条件
/// 条件
/// </summary>
public List<ConditionDetail> Conditions { get; set; }
public List<ConditionDetail> Conditions { get; set; } = [];
/// <summary>
/// 条件组
@ -21,6 +21,11 @@
/// 数据源名称
/// </summary>
public string? SourceName { get; set; }
/// <summary>
/// 附加数据项
/// </summary>
public object? ExtraData { get; set; }
}
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.Data;
using SqlSugar;
namespace DS.WMS.Core.Fee.Entity
{
/// <summary>
/// 往来单位固定费用
/// 往来单位费用模板明细
/// </summary>
[SugarTable("fee_cust_template_detail", "往来单位固定费用")]
public class FeeCustTemplateDetail : BaseModelV2<long>
[SugarTable("fee_cust_template_detail", "往来单位费用模板明细")]
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>
/// 费用Id
/// </summary>
@ -19,17 +33,22 @@ namespace DS.WMS.Core.Fee.Entity
/// 费用代码 录入费用是作为检索
/// </summary>
[SugarColumn(ColumnDescription = "费用代码", Length = 50, IsNullable = true)]
public string FeeCode { get; set; }
public string? FeeCode { get; set; }
/// <summary>
/// 费用名称
/// </summary>
[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>
[SugarColumn(ColumnDescription = "结算对象", Length = 100, IsNullable = true)]
public string CustomerName { get; set; }
public string? CustomerName { get; set; }
/// <summary>
/// 客户类型
/// </summary>
@ -39,28 +58,22 @@ namespace DS.WMS.Core.Fee.Entity
/// 收付类型(收、付)
/// </summary>
[SugarColumn(ColumnDescription = "收付类型(收、付)", IsNullable = false, DefaultValue = "1")]
public int FeeType { get; set; }
/// <summary>
/// 客户Id
/// </summary>
[SugarColumn(ColumnDescription = "客户Id")]
public long CustomerId { get; set; }
public FeeType FeeType { get; set; }
/// <summary>
/// 费用标准
/// </summary>
[SugarColumn(ColumnDescription = "费用标准", Length = 20, IsNullable = true)]
public string Unit { get; set; }
public string? Unit { get; set; }
/// <summary>
/// 是否箱型
/// </summary>
[SugarColumn(ColumnDescription = "是否箱型", DefaultValue = "0")]
public bool? IsCtn { get; set; } = false;
public bool IsCtn { get; set; }
/// <summary>
/// 币别
/// </summary>
[SugarColumn(ColumnDescription = "币别", Length = 100, IsNullable = true)]
public string Currency { get; set; }
public string? Currency { get; set; }
/// <summary>
/// 单价
/// </summary>
@ -70,8 +83,7 @@ namespace DS.WMS.Core.Fee.Entity
/// 排序
/// </summary>
[SugarColumn(ColumnDescription = "排序")]
public int? OrderNo { get; set; } = 100;
public int OrderNo { get; set; } = 100;
/// <summary>
/// 汇率
/// </summary>
@ -101,13 +113,21 @@ namespace DS.WMS.Core.Fee.Entity
/// 是否开票
/// </summary>
[SugarColumn(ColumnDescription = "是否开票", DefaultValue = "0")]
public bool? IsInvoice { get; set; } = false;
public bool IsInvoice { get; set; }
/// <summary>
/// 是否垫付费用
/// </summary>
[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>
[SugarColumn(ColumnDescription = "费用标准", Length = 20, IsNullable = true)]
public string Unit { get; set; }
public string? Unit { get; set; }
/// <summary>
/// 费用标准文本
/// </summary>
@ -323,7 +323,7 @@ namespace DS.WMS.Core.Fee.Entity
/// 本位币
/// </summary>
[SugarColumn(ColumnDescription = "本位币", IsNullable = true, Length = 30)]
public string LocalCurrency { get; set; } = "CNY";
public string? LocalCurrency { get; set; }
/// <summary>
/// 责任人

@ -4,6 +4,9 @@ using DS.WMS.Core.Fee.Dtos;
namespace DS.WMS.Core.Fee.Interface;
/// <summary>
/// 往来单位费用模板明细
/// </summary>
public interface IFeeCustTemplateDetailService
{
/// <summary>
@ -13,13 +16,12 @@ public interface IFeeCustTemplateDetailService
/// <returns></returns>
DataResult<List<FeeCustTemplateDetailRes>> GetListByPage(PageRequest request);
/// <summary>
/// 编辑
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
DataResult EditFeeCustTemplateDetail(FeeCustTemplateDetailReq model);
Task<DataResult> EditAsync(FeeCustTemplateDetailReq model);
/// <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
{
/// <summary>
/// 往来单位固定费用
/// 往来单位费用模板明细
/// </summary>
public class FeeCustTemplateDetailService : FeeServiceBase, IFeeCustTemplateDetailService
{
@ -30,8 +30,7 @@ namespace DS.WMS.Core.Fee.Method
{
//序列化查询条件
var whereList = request.GetConditionalModels(Db);
var data = TenantDb.Queryable<FeeCustTemplateDetail>()
.Where(whereList)
var data = TenantDb.Queryable<FeeCustTemplateDetail>().Where(whereList)
.Select<FeeCustTemplateDetailRes>().ToQueryPage(request.PageCondition);
return data;
}
@ -41,29 +40,24 @@ namespace DS.WMS.Core.Fee.Method
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public DataResult EditFeeCustTemplateDetail(FeeCustTemplateDetailReq req)
public async Task<DataResult> EditAsync(FeeCustTemplateDetailReq req)
{
if (req.Id == 0)
{
if (TenantDb.Queryable<FeeCustTemplateDetail>()
.Where(x => x.FeeId == req.FeeId && x.CustomerId == req.CustomerId && x.FeeType == req.FeeType).Any())
{
if (TenantDb.Queryable<FeeCustTemplateDetail>().Where(x =>
x.FeeId == req.FeeId && x.CustomerId == req.CustomerId && x.FeeType == req.FeeType).Any())
return DataResult.Failed("往来单位固定费用已存在!", MultiLanguageConst.FeeCustTemplateDetailExist);
}
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);
}
else
{
var info = TenantDb.Queryable<FeeCustTemplateDetail>().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);
}
}

@ -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>
public async Task<DataResult> SaveAsync(IEnumerable<FeeRecord> 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<SysOrg>().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;
}

@ -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
/// <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>
/// <returns></returns>
Task<bool> IsMatchAsync(TaskRequest request, IEnumerable<ConditionContent> conditions);
Task<bool> IsMatchAsync(long bsId, BusinessType businessType, IEnumerable<ConditionContent> conditions);
/// <summary>
/// 获取所需业务数据
@ -45,22 +53,6 @@ namespace DS.WMS.Core.Op.Interface.TaskInteraction
/// <returns></returns>
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>

@ -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,40 +36,40 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
/// <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>
/// <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));
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;
}
}
}
return false;
}
@ -134,53 +135,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
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>

@ -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; }
/// <summary>
/// 规则引擎服务
/// 规则服务
/// </summary>
protected Lazy<IRuleEngineService> RuleEngineService { get; private set; }
/// <summary>
/// 费用模板服务
/// </summary>
protected Lazy<IFeeCustTemplateService> FeeTemplateService { get; private set; }
/// <summary>
/// 初始化
/// </summary>
@ -95,6 +101,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
FlowService = new Lazy<IClientFlowInstanceService>(provider.GetRequiredService<IClientFlowInstanceService>());
RuleEngineService = new Lazy<IRuleEngineService>(provider.GetRequiredService<IRuleEngineService>());
FeeTemplateService = new Lazy<IFeeCustTemplateService>(provider.GetRequiredService<IFeeCustTemplateService>());
TenantDb.QueryFilter.Clear<IOrgId>();
}
@ -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

@ -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;
}

Loading…
Cancel
Save