zhangxiaofeng 3 months ago
commit 044dda9fb3

@ -81,7 +81,8 @@ namespace DS.Module.DjyRulesEngine
Port = port, Port = port,
Path = sendUrl Path = sendUrl
}; };
var result = await api.PostAsync<RuleEngineResult>(uriBuilder.ToString(), req); string url = uriBuilder.ToString();
var result = await api.PostAsync<RuleEngineResult>(url, req);
if (!result.Succeeded || result.Data == null) if (!result.Succeeded || result.Data == null)
return RuleEngineResult.Failed("请求失败,请联系管理员"); return RuleEngineResult.Failed("请求失败,请联系管理员");

@ -16,16 +16,30 @@ namespace DS.WMS.AdminApi.Controllers;
public class CommonController : ApiController public class CommonController : ApiController
{ {
private readonly ICommonService _invokeService; private readonly ICommonService _invokeService;
private readonly IServerCommonService _serverService;
/// <summary> /// <summary>
/// 构造函数 /// 构造函数
/// </summary> /// </summary>
/// <param name="invokeService"></param> /// <param name="invokeService"></param>
public CommonController(ICommonService invokeService) public CommonController(ICommonService invokeService, IServerCommonService serverService)
{ {
_invokeService = invokeService; _invokeService = invokeService;
_serverService = serverService;
} }
/// <summary>
/// 获取船公司下拉列表
/// </summary>
/// <param name="queryKey">船公司代码或中文名称</param>
/// <returns></returns>
[HttpGet]
[Route("GetCarrierSelectList")]
public async Task<DataResult<List<CodeCarrierRes>>> GetCarrierSelectList([FromQuery] string queryKey)
{
var res = await _serverService.GetCodeCarrierSelectList(queryKey);
return res;
}
/// <summary> /// <summary>
/// 用户登录-管理端 /// 用户登录-管理端
/// </summary> /// </summary>

@ -29,39 +29,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking
return Task.CompletedTask; return Task.CompletedTask;
} }
protected async Task<DataResult> CreateTaskIfNotExistAsync(ActionExecutionContext context)
{
if (!context.TaskInfo.NextType.HasValue)
return DataResult.Success;
var result = await TaskService.ExistsAsync(context.TaskInfo.BusinessId, context.TaskInfo.BusinessType, context.TaskInfo.NextType.Value);
//任务已存在,跳过创建步骤
if (result.Data)
return DataResult.Success;
return await TaskService.CreateTaskAsync(new TaskCreationRequest
{
BusinessId = context.TaskInfo.BusinessId,
BusinessType = context.TaskInfo.BusinessType,
TaskTypeName = context.TaskInfo.NextType.Value.ToString()
});
}
protected async Task SetTaskCompleteAsync(ActionExecutionContext context)
{
if (!context.TaskInfo.NextType.HasValue)
return;
var result = await TaskService.SetTaskStatusAsync(new TaskUpdateRequest
{
BusinessId = context.TaskInfo.BusinessId,
BusinessType = context.TaskInfo.BusinessType,
TaskTypeName = context.TaskInfo.NextType.Value.ToString(),
TaskStatus = TaskStatusEnum.Complete,
AutoCreateNext = true
});
if (!result.Succeeded)
await LogService.WriteLogAsync(context.TaskInfo, $"未能设置任务【{context.TaskInfo.NextType.Value.GetDescription()}】完成,返回结果:{result.Message}");
}
} }
} }

@ -1,7 +1,7 @@
using DS.WMS.Core.Op.Dtos; using DS.Module.Core;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.Dtos.TaskInteraction; using DS.WMS.Core.Op.Dtos.TaskInteraction;
using DS.WMS.Core.Op.Interface; using DS.WMS.Core.Op.Interface;
using Masuit.Tools.Systems;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking
@ -11,7 +11,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking
/// </summary> /// </summary>
public class EDIActionExecutor : BookingActionExecutor public class EDIActionExecutor : BookingActionExecutor
{ {
public async override Task ExecuteAsync(ActionExecutionContext context) public async override Task ExecuteAsync(ActionExecutionContext context)
{ {
await base.ExecuteAsync(context); await base.ExecuteAsync(context);
@ -41,7 +40,9 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking
return; return;
} }
await SetTaskCompleteAsync(context); var task = context.TaskInfo;
task.TaskType = TaskBaseTypeEnum.WAIT_BOOKING;
await SetTaskCompleteAsync(task, TaskService, LogService);
} }
} }
} }

@ -1,4 +1,5 @@
using DS.WMS.Core.Op.Dtos; using DS.Module.Core;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.Dtos.TaskInteraction; 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;
@ -79,7 +80,9 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking
return; return;
} }
await SetTaskCompleteAsync(context); var task = context.TaskInfo;
task.TaskType = TaskBaseTypeEnum.WAIT_BOOKING;
await SetTaskCompleteAsync(task, TaskService, LogService);
} }
} }

@ -1,6 +1,9 @@
using DS.Module.Core; using DS.Module.Core;
using DS.WMS.Core.Op.Dtos.TaskInteraction; using DS.WMS.Core.Op.Dtos.TaskInteraction;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Op.Entity.TaskInteraction;
using DS.WMS.Core.Op.Interface.TaskInteraction; using DS.WMS.Core.Op.Interface.TaskInteraction;
using Masuit.Tools.Systems;
namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor
{ {
@ -25,5 +28,57 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor
{ {
return Task.CompletedTask; return Task.CompletedTask;
} }
/// <summary>
/// 如果指定类型的任务不存在则创建
/// </summary>
/// <param name="bsId">业务ID</param>
/// <param name="type">业务类型</param>
/// <param name="taskType">任务类型</param>
/// <param name="taskService">任务服务</param>
/// <param name="logService">任务日志服务</param>
/// <returns></returns>
protected async Task<DataResult> CreateTaskIfNotExistAsync(long bsId, BusinessType type, TaskBaseTypeEnum taskType,
ITaskService taskService, ITaskLogService? logService = null)
{
ArgumentNullException.ThrowIfNull(taskService, nameof(taskService));
var result = await taskService.ExistsAsync(bsId, type, taskType);
//任务已存在,跳过创建步骤
if (result.Data)
return DataResult.Success;
return await taskService.CreateTaskAsync(new TaskCreationRequest
{
BusinessId = bsId,
BusinessType = type,
TaskTypeName = taskType.ToString()
});
}
/// <summary>
/// 设置任务状态为完成
/// </summary>
/// <param name="task">任务对象</param>
/// <param name="taskService">任务服务</param>
/// <param name="logService">任务日志服务</param>
/// <returns></returns>
protected virtual async Task SetTaskCompleteAsync(BusinessTask task, ITaskService taskService, ITaskLogService? logService = null)
{
ArgumentNullException.ThrowIfNull(task, nameof(task));
ArgumentNullException.ThrowIfNull(taskService, nameof(taskService));
var result = await taskService.SetTaskStatusAsync(new TaskUpdateRequest
{
BusinessId = task.BusinessId,
BusinessType = task.BusinessType,
TaskTypeName = task.TaskType.ToString(),
TaskStatus = TaskStatusEnum.Complete,
AutoCreateNext = true
});
if (!result.Succeeded && logService != null)
await logService.WriteLogAsync(task, $"未能设置任务【{task.NextType?.GetDescription()}】完成,返回结果:{result.Message}");
}
} }
} }

@ -108,16 +108,27 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.SpaceRelease
await LogService.WriteLogAsync(context.TaskInfo, result.Message); await LogService.WriteLogAsync(context.TaskInfo, result.Message);
return; return;
} }
await SetTaskCompleteAsync(context.TaskInfo,
context.ServiceProvider.GetRequiredService<ITaskService>(), LogService);
} }
//转发BC //转发BC
async Task RelayBCAsync(ActionExecutionContext context) async Task RelayBCAsync(ActionExecutionContext context)
{ {
var taskBase = context.AdditionalData[TaskFlowDataNameConst.TaskBaseInfo] as TaskBaseInfo; var taskBase = context.AdditionalData[TaskFlowDataNameConst.TaskBaseInfo] as TaskBaseInfo;
if (taskBase != null) if (taskBase == null)
await BCService.SyncBookingSlotChange(taskBase.Id); return;
var result = await BCService.SyncBookingSlotChange(taskBase.Id);
if (!result.Succeeded)
return;
await SetTaskCompleteAsync(context.TaskInfo,
context.ServiceProvider.GetRequiredService<ITaskService>(), LogService);
} }
//下货纸 //下货纸
async Task SendShippingOrderAsync(ActionExecutionContext context) async Task SendShippingOrderAsync(ActionExecutionContext context)
{ {

@ -115,14 +115,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
if (task != null && task.TaskStatus != TaskStatusEnum.Cancel) if (task != null && task.TaskStatus != TaskStatusEnum.Cancel)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskExists)); return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskExists));
//审核任务需要校验订单规则
if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT)
{
var result = await CheckOrderRulesAsync(request.BusinessId);
if (!result.Succeeded)
return result;
}
long tenatId = long.Parse(User.TenantId); long tenatId = long.Parse(User.TenantId);
string tenatName = Db.Queryable<SysTenant>().Where(x => x.Id == tenatId).Select(x => x.Name).First(); string tenatName = Db.Queryable<SysTenant>().Where(x => x.Id == tenatId).Select(x => x.Name).First();
var info = new TaskManageOrderMessageInfo var info = new TaskManageOrderMessageInfo
@ -216,6 +208,28 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
//审核任务需创建工作流 //审核任务需创建工作流
if (AuditTaskTypes.Contains(request.TaskType)) if (AuditTaskTypes.Contains(request.TaskType))
{ {
if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT)
{
var rulesReq = new RuleEngineReq();
rulesReq.Head.MessageType = "BUSI_RULE";
rulesReq.Head.SenderId = "NewOceanBooking";
rulesReq.Head.RequestAction = "CheckRule";
rulesReq.Main.ProjectCode = ["COMMON_OCEAN_BOOKING"];
var order = await TenantDb.Queryable<SeaExport>().Where(x => x.Id == request.BusinessId).FirstAsync();
rulesReq.Main.BusinessInfo = info.Adapt<RulesEngineOrderBookingMainBusinessInfo>();
var ruleResult = await RuleEngineService.Value.ExecuteSeaExportAuditRulesAsync(rulesReq);
if (ruleResult?.Extra.DetailList?.Count > 0)
{
StringBuilder sb = new StringBuilder();
foreach (var item in ruleResult?.Extra.DetailList)
sb.Append(item.ResultName);
return DataResult.Failed(sb.ToString());
}
}
result = await CreateAndStartWorkflow(task); result = await CreateAndStartWorkflow(task);
if (!result.Succeeded) if (!result.Succeeded)
return result; return result;
@ -346,8 +360,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
{ {
BusinessId = request.BusinessId, BusinessId = request.BusinessId,
BusinessType = request.BusinessType, BusinessType = request.BusinessType,
TaskTypeName = task.NextType.Value.ToString(), TaskTypeName = task.NextType.Value.ToString()
RecvUserIdList = task.RecvUserIdArray
}; };
result = await CreateTaskAsync(req, false); result = await CreateTaskAsync(req, false);
if (!result.Succeeded) if (!result.Succeeded)
@ -363,7 +376,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
if (task.TaskStatus == TaskStatusEnum.Complete)//目前限制任务完成才触发 if (task.TaskStatus == TaskStatusEnum.Complete)//目前限制任务完成才触发
{ {
Dictionary<string, object>? dic = null; Dictionary<string, object>? dic = null;
if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT) if (task.NextType == TaskBaseTypeEnum.WAIT_BOOKING)
{ {
dic = new Dictionary<string, object>(); dic = new Dictionary<string, object>();
var param = await ClientParamService.GetParamAsync<string>(task.BusinessId, BookingSelector.Booking_Route, var param = await ClientParamService.GetParamAsync<string>(task.BusinessId, BookingSelector.Booking_Route,
@ -461,14 +474,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
if (task.TaskStatus == TaskStatusEnum.Pending || task.TaskStatus == TaskStatusEnum.Create) if (task.TaskStatus == TaskStatusEnum.Pending || task.TaskStatus == TaskStatusEnum.Create)
{ {
//审核任务需要校验订单规则
if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT)
{
var result = await CheckOrderRulesAsync(request.BusinessId);
if (!result.Succeeded)
return result;
}
await TenantDb.Ado.BeginTranAsync(); await TenantDb.Ado.BeginTranAsync();
try try
{ {
@ -627,7 +632,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
BusinessType = callback.BusinessType.Value, BusinessType = callback.BusinessType.Value,
TaskTypeName = taskType.ToString(), TaskTypeName = taskType.ToString(),
TaskStatus = callback.FlowStatus == FlowStatusEnum.Approve ? TaskStatusEnum.Complete : TaskStatusEnum.Pending, TaskStatus = callback.FlowStatus == FlowStatusEnum.Approve ? TaskStatusEnum.Complete : TaskStatusEnum.Pending,
AutoCreateNext = false //审批完成后需根据业务需要自定义任务类型,因此设置为不自动创建下一任务 AutoCreateNext = true
}; };
//根据审批结果更新任务状态 //根据审批结果更新任务状态
await SetTaskStatusAsync(req); await SetTaskStatusAsync(req);
@ -668,34 +673,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
}); });
} }
async Task<DataResult> CheckOrderRulesAsync(long businessId)
{
var rulesReq = new RuleEngineReq();
rulesReq.Head.MessageType = "BUSI_RULE";
rulesReq.Head.SenderId = "NewOceanBooking";
rulesReq.Head.RequestAction = "CheckRule";
rulesReq.Main.ProjectCode = ["COMMON_OCEAN_BOOKING"];
var order = await TenantDb.Queryable<SeaExport>().Where(x => x.Id == businessId).FirstAsync();
if (order == null)
return DataResult.FailedWithDesc(MultiLanguageConst.EmptyData);
rulesReq.Main.BusinessInfo = order.Adapt<RulesEngineOrderBookingMainBusinessInfo>();
var ruleResult = await RuleEngineService.Value.ExecuteSeaExportAuditRulesAsync(rulesReq);
if (ruleResult?.Extra.DetailList?.Count > 0)
{
StringBuilder sb = new StringBuilder();
foreach (var item in ruleResult?.Extra.DetailList)
sb.Append(" " + item.ResultName);
sb.Remove(0, 1);
return DataResult.Failed(sb.ToString());
}
return DataResult.Success;
}
/// <summary> /// <summary>
/// 获取给定任务的下一任务类型 /// 获取给定任务的下一任务类型
/// </summary> /// </summary>

@ -0,0 +1,23 @@
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Info.Dtos;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Sys.Dtos;
using DS.WMS.Core.Sys.Entity;
using SqlSugar;
namespace DS.WMS.Core.Sys.Interface;
/// <summary>
///
/// </summary>
public interface IServerCommonService
{
/// <summary>
/// 获取船公司下拉列表-管理端
/// </summary>
/// <returns></returns>
public Task<DataResult<List<CodeCarrierRes>>> GetCodeCarrierSelectList(string queryKey = "");
}

@ -1,6 +1,5 @@
using DS.Module.Core; using DS.Module.Core;
using DS.Module.Core.Constants; using DS.Module.Core.Constants;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions; using DS.Module.Core.Extensions;
using DS.Module.Core.Log; using DS.Module.Core.Log;
using DS.Module.SqlSugar; using DS.Module.SqlSugar;
@ -11,21 +10,14 @@ using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Entity; using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Info.Dtos; using DS.WMS.Core.Info.Dtos;
using DS.WMS.Core.Info.Entity; using DS.WMS.Core.Info.Entity;
using DS.WMS.Core.Invoice.Dtos;
using DS.WMS.Core.Op.Dtos; using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.EDI;
using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Dtos; using DS.WMS.Core.Sys.Dtos;
using DS.WMS.Core.Sys.Entity; using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.Sys.Interface; using DS.WMS.Core.Sys.Interface;
using Mapster; using Mapster;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using NPOI.POIFS.Crypt.Dsig;
using SqlSugar; using SqlSugar;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace DS.WMS.Core.Sys.Method; namespace DS.WMS.Core.Sys.Method;

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DS.Module.Core;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Sys.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using DS.Module.Core;
using DS.Module.Core.Constants;
using DS.Module.Core.Extensions;
using DS.Module.Core.Log;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Code.Entity;
namespace DS.WMS.Core.Sys.Method
{
public class ServerCommonService : IServerCommonService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public ServerCommonService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
}
/// <summary>
///
/// </summary>
/// <param name="queryKey"></param>
/// <returns></returns>
public async Task<DataResult<List<CodeCarrierRes>>> GetCodeCarrierSelectList(string queryKey = "")
{
var list = await db.Queryable<CodeCarrier>()
.WhereIF(!string.IsNullOrEmpty(queryKey), a => a.Code.Contains(queryKey) || a.CnName.Contains(queryKey))
.Select(a => new CodeCarrierRes()
{
PinYinCode = a.CnName + "(" + a.Code + ")",
},
true)
.Take(20)
.ToListAsync();
return await Task.FromResult(DataResult<List<CodeCarrierRes>>.Success("获取数据成功!", list));
}
}
}
Loading…
Cancel
Save