|
|
|
@ -3,7 +3,7 @@ using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Data;
|
|
|
|
|
using DS.Module.Core.Helpers;
|
|
|
|
|
using DS.Module.DjyRulesEngine;
|
|
|
|
|
using DS.WMS.Core.Application.Dtos;
|
|
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
|
|
using DS.WMS.Core.Flow.Dtos;
|
|
|
|
|
using DS.WMS.Core.Flow.Entity;
|
|
|
|
|
using DS.WMS.Core.Flow.Interface;
|
|
|
|
@ -24,7 +24,6 @@ using Masuit.Tools;
|
|
|
|
|
using Masuit.Tools.Systems;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
@ -46,6 +45,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
/// </summary>
|
|
|
|
|
static readonly TaskBaseTypeEnum[] AuditTaskTypesManualReject;
|
|
|
|
|
|
|
|
|
|
internal static readonly TaskBaseTypeEnum[] FeeTypes = [TaskBaseTypeEnum.FEE_AUDIT, TaskBaseTypeEnum.FEE_MODIFY_AUDIT, TaskBaseTypeEnum.FEE_DELETE_AUDIT];
|
|
|
|
|
|
|
|
|
|
static readonly ApiFox Api;
|
|
|
|
|
|
|
|
|
|
static TaskService()
|
|
|
|
@ -331,9 +332,35 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
}
|
|
|
|
|
info.Main.TaskDesp = info.Main.TaskDesp ?? info.Main.TaskTitle;
|
|
|
|
|
|
|
|
|
|
//费用审核且多个接收人需拆分任务
|
|
|
|
|
if (FeeTypes.Contains(request.TaskType) && info.Main.RecvUserInfoList.Count > 1)
|
|
|
|
|
{
|
|
|
|
|
var fee = await TenantDb.Queryable<FeeRecord>().Where(x => x.Id == request.BusinessId)
|
|
|
|
|
.Select(x => new
|
|
|
|
|
{
|
|
|
|
|
x.BusinessId,
|
|
|
|
|
x.BusinessType
|
|
|
|
|
}).FirstAsync();
|
|
|
|
|
var recvUserList = new List<RecvUserInfo>(info.Main.RecvUserInfoList); //复制接收人列表
|
|
|
|
|
foreach (var item in recvUserList)
|
|
|
|
|
{
|
|
|
|
|
var copiedInfo = info.DeepClone();
|
|
|
|
|
copiedInfo.Head.BSNO = fee.BusinessId; //替换为费用关联的订单ID
|
|
|
|
|
|
|
|
|
|
copiedInfo.Main.RecvUserInfoList.Clear();
|
|
|
|
|
copiedInfo.Main.RecvUserInfoList.Add(item);
|
|
|
|
|
|
|
|
|
|
result = await ManagerService.InitTaskJob(info);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result = await ManagerService.InitTaskJob(info);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
task = new BusinessTask
|
|
|
|
|
{
|
|
|
|
@ -492,10 +519,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
//if (task.TaskStatus == TaskStatusEnum.Cancel)
|
|
|
|
|
// return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCancelled));
|
|
|
|
|
|
|
|
|
|
var result = await ManagerService.SetTaskStatusWithBsno(request.BusinessId, request.TaskType, request.TaskStatus, DateTime.Now, request.TaskDesc);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return DataResult.Failed(result.Message, result.MultiCode);
|
|
|
|
|
|
|
|
|
|
//触发任务状态变更通知
|
|
|
|
|
if (task.TaskStatus != request.TaskStatus)
|
|
|
|
|
await OnTaskStatusChanged(request);
|
|
|
|
@ -505,6 +528,43 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
task.TaskStatus = request.TaskStatus;
|
|
|
|
|
await TenantDb.Updateable(task).UpdateColumns(x => new { x.TaskStatus, x.RejectReason }).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
DataResult result;
|
|
|
|
|
if (FeeTypes.Contains(request.TaskType))
|
|
|
|
|
{
|
|
|
|
|
var fee = await TenantDb.Queryable<FeeRecord>().Where(x => x.Id == request.BusinessId)
|
|
|
|
|
.Select(x => new
|
|
|
|
|
{
|
|
|
|
|
x.BusinessId,
|
|
|
|
|
x.BusinessType
|
|
|
|
|
}).FirstAsync();
|
|
|
|
|
|
|
|
|
|
var relativeTasks = await TenantDb.Queryable<BusinessTask>()
|
|
|
|
|
.InnerJoin<FeeRecord>((t, f) => t.BusinessId == f.Id)
|
|
|
|
|
.Where((t, f) => f.BusinessId == fee.BusinessId && f.BusinessType == fee.BusinessType && FeeTypes.Contains(t.TaskType) && t.RecvUsers.Contains(User.UserId))
|
|
|
|
|
.Select((t, f) => new
|
|
|
|
|
{
|
|
|
|
|
t.Id,
|
|
|
|
|
t.BusinessId,
|
|
|
|
|
t.TaskType,
|
|
|
|
|
t.TaskStatus,
|
|
|
|
|
t.RecvUsers
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
var groups = relativeTasks.GroupBy(x => x.TaskStatus).Select(x => x.Key).ToList();
|
|
|
|
|
if (groups.Count == 1 && groups.All(x => x == request.TaskStatus))
|
|
|
|
|
{
|
|
|
|
|
result = await ManagerService.SetTaskStatusWithBsno(request.BusinessId, request.TaskType, request.TaskStatus, DateTime.Now, request.TaskDesc);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return DataResult.Failed(result.Message, result.MultiCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result = await ManagerService.SetTaskStatusWithBsno(request.BusinessId, request.TaskType, request.TaskStatus, DateTime.Now, request.TaskDesc);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return DataResult.Failed(result.Message, result.MultiCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (task.TaskStatus == TaskStatusEnum.Complete && task.NextType.HasValue && request.AutoCreateNext)
|
|
|
|
|
{
|
|
|
|
|
//存在下一任务,则继续创建
|
|
|
|
@ -612,7 +672,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 发起任务审核
|
|
|
|
|
/// 重新发起任务审核
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <param name="useTransaction">是否使用事务</param>
|
|
|
|
@ -845,28 +905,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
//根据审批结果更新任务状态
|
|
|
|
|
await SetTaskStatusAsync(req);
|
|
|
|
|
|
|
|
|
|
////终审通过且任务类型为审单,则生成费用
|
|
|
|
|
//if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT && instance.IsCompleted)
|
|
|
|
|
//{
|
|
|
|
|
// UriBuilder builder = new(configuration["FeeService:BaseUrl"])
|
|
|
|
|
// {
|
|
|
|
|
// Path = configuration["FeeService:GenerateFees"]
|
|
|
|
|
// };
|
|
|
|
|
// string url = builder.ToString();
|
|
|
|
|
// if (string.IsNullOrEmpty(url))
|
|
|
|
|
// {
|
|
|
|
|
// await LogService.WriteLogAsync(req, "未在配置文件中配置费用服务URL,无法根据费用模板生成费用");
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// string json = JsonConvert.SerializeObject(new BizItem
|
|
|
|
|
// {
|
|
|
|
|
// Id = req.BusinessId,
|
|
|
|
|
// BusinessType = req.BusinessType.GetValueOrDefault()
|
|
|
|
|
// });
|
|
|
|
|
// Api.SendRequestAsync(HttpMethod.Post, url, json);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
if (instance.FlowStatus == FlowStatusEnum.Reject)
|
|
|
|
|
result.Message = MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskRejected));
|
|
|
|
|
|
|
|
|
@ -1064,19 +1102,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
.WhereIF(taskTypes != null && taskTypes.Length > 0, x => taskTypes.Contains(x.TaskType));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取指定业务ID的任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="taskType">任务类型</param>
|
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
|
/// <param name="ids">业务ID</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected internal ISugarQueryable<BusinessTask> GetQuery(TaskBaseTypeEnum taskType, BusinessType? businessType, params long[] ids)
|
|
|
|
|
{
|
|
|
|
|
return TenantDb.Queryable<BusinessTask>().Where(x => x.TaskType == taskType && ids.Contains(x.BusinessId))
|
|
|
|
|
.WhereIF(businessType.HasValue, x => x.BusinessType == businessType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 从任务配置中获取接收用户列表
|
|
|
|
|
/// </summary>
|
|
|
|
|