cjy 1 month ago
commit fc5ef6762e

@ -59,5 +59,12 @@ namespace DS.WMS.Core.Info.Interface
/// <param name="stakeholder">干系人</param>
/// <returns></returns>
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);
result.Code = ResultCode.Fail;
result.Data = client;
return result;
}
TenantDb.QueryFilter.Restore();

@ -271,5 +271,15 @@ namespace DS.WMS.Core.Info.Method
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.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;
result = await ManagerService.InitTaskJob(info);
if (!result.Succeeded)
return result;
//费用审核且多个接收人需拆分任务
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>

@ -103,6 +103,26 @@ namespace DS.WMS.MainApi.Controllers
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>

Loading…
Cancel
Save