cjy 2 months ago
commit fc5ef6762e

@ -59,5 +59,12 @@ namespace DS.WMS.Core.Info.Interface
/// <param name="stakeholder">干系人</param> /// <param name="stakeholder">干系人</param>
/// <returns></returns> /// <returns></returns>
Task<DataResult> EditAsync(InfoClientStakeholder stakeholder); Task<DataResult> EditAsync(InfoClientStakeholder stakeholder);
/// <summary>
/// 创建客户干系人并提交审核
/// </summary>
/// <param name="stakeholder">干系人</param>
/// <returns></returns>
Task<DataResult> AddSubmitAsync(InfoClientStakeholder stakeholder);
} }
} }

@ -574,6 +574,7 @@ public class ClientInfoService : ServiceBase, IClientInfoService
var result = DataResult.Failed("客户信息已存在,请检查客户全称/简称是否重复!", MultiLanguageConst.ClientInfoExist); var result = DataResult.Failed("客户信息已存在,请检查客户全称/简称是否重复!", MultiLanguageConst.ClientInfoExist);
result.Code = ResultCode.Fail; result.Code = ResultCode.Fail;
result.Data = client; result.Data = client;
return result;
} }
TenantDb.QueryFilter.Restore(); TenantDb.QueryFilter.Restore();

@ -271,5 +271,15 @@ namespace DS.WMS.Core.Info.Method
return result; return result;
} }
/// <summary>
/// 创建客户干系人并提交审核
/// </summary>
/// <param name="stakeholder">干系人</param>
/// <returns></returns>
public async Task<DataResult> AddSubmitAsync(InfoClientStakeholder stakeholder)
{
await TenantDb.Insertable(stakeholder).ExecuteCommandAsync();
return await SubmitAuditAsync(new IdModel { Id = stakeholder.Id.ToString(), Ids = [stakeholder.Id] });
}
} }
} }

@ -3,7 +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.Application.Dtos; using DS.WMS.Core.Fee.Entity;
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;
@ -24,7 +24,6 @@ using Masuit.Tools;
using Masuit.Tools.Systems; using Masuit.Tools.Systems;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using SqlSugar; using SqlSugar;
namespace DS.WMS.Core.Op.Method.TaskInteraction namespace DS.WMS.Core.Op.Method.TaskInteraction
@ -46,6 +45,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
/// </summary> /// </summary>
static readonly TaskBaseTypeEnum[] AuditTaskTypesManualReject; 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 readonly ApiFox Api;
static TaskService() static TaskService()
@ -331,9 +332,35 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
} }
info.Main.TaskDesp = info.Main.TaskDesp ?? info.Main.TaskTitle; 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); result = await ManagerService.InitTaskJob(info);
if (!result.Succeeded) if (!result.Succeeded)
return result; return result;
}
task = new BusinessTask task = new BusinessTask
{ {
@ -492,10 +519,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
//if (task.TaskStatus == TaskStatusEnum.Cancel) //if (task.TaskStatus == TaskStatusEnum.Cancel)
// return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCancelled)); // 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) if (task.TaskStatus != request.TaskStatus)
await OnTaskStatusChanged(request); await OnTaskStatusChanged(request);
@ -505,6 +528,43 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
task.TaskStatus = request.TaskStatus; task.TaskStatus = request.TaskStatus;
await TenantDb.Updateable(task).UpdateColumns(x => new { x.TaskStatus, x.RejectReason }).ExecuteCommandAsync(); 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) if (task.TaskStatus == TaskStatusEnum.Complete && task.NextType.HasValue && request.AutoCreateNext)
{ {
//存在下一任务,则继续创建 //存在下一任务,则继续创建
@ -612,7 +672,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
} }
/// <summary> /// <summary>
/// 发起任务审核 /// 重新发起任务审核
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <param name="useTransaction">是否使用事务</param> /// <param name="useTransaction">是否使用事务</param>
@ -845,28 +905,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
//根据审批结果更新任务状态 //根据审批结果更新任务状态
await SetTaskStatusAsync(req); 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) if (instance.FlowStatus == FlowStatusEnum.Reject)
result.Message = MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskRejected)); 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)); .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>
/// 从任务配置中获取接收用户列表 /// 从任务配置中获取接收用户列表
/// </summary> /// </summary>

@ -103,6 +103,26 @@ namespace DS.WMS.MainApi.Controllers
return await _invokeService.GetAsync(id); return await _invokeService.GetAsync(id);
} }
/// <summary>
/// 创建客户干系人并提交审核
/// </summary>
/// <param name="clientId">客户ID</param>
/// <returns></returns>
[HttpPost, Route("CreateSubmit")]
public async Task<DataResult> AddSubmitAsync(long clientId)
{
var date = DateTime.Now.Date;
return await _invokeService.AddSubmitAsync(new InfoClientStakeholder
{
ClientId = clientId,
CreateBy = long.Parse(_user.UserId),
CreateByName = _user.UserName,
StartDate = date,
EndDate = date.AddMonths(4),
Status = StakeholderStatus.Uncommitted
});
}
/// <summary> /// <summary>
/// 新增客户干系人 /// 新增客户干系人
/// </summary> /// </summary>

Loading…
Cancel
Save