dengyu 3 months ago
commit 1ceca6013b

@ -80,7 +80,7 @@ public interface IClientFlowInstanceService
/// <param name="ids"></param>
/// <param name="note">备注</param>
/// <returns></returns>
Task<DataResult> WithdrawFlowInstanceAsync(long[] ids, string? note = null);
Task<DataResult> WithdrawAsync(long[] ids, string? note = null);
/// <summary>
/// 获取流程操作历史

@ -7,7 +7,6 @@ using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Entity;
using Mapster;
using Masuit.Tools.Systems;
using MathNet.Numerics;
namespace DS.WMS.Core.Flow.Method;
@ -36,7 +35,8 @@ public class ClientFlowInstanceService : FlowInstanceService, IClientFlowInstanc
if (ids == null || ids.Length == 0)
return [];
return await Db.Queryable<FlowInstance>().Where(x => x.Type == type && ids.Contains(x.BusinessId))
return await Db.Queryable<FlowInstance>().Where(x => x.Type == type && ids.Contains(x.BusinessId) &&
(x.FlowStatus == FlowStatusEnum.Ready || x.FlowStatus == FlowStatusEnum.Running))
.WhereIF(businessType.HasValue, x => x.BusinessType == businessType)
.OrderByDescending(x => x.CreateTime).Take(1).ToListAsync();
}
@ -152,7 +152,7 @@ public class ClientFlowInstanceService : FlowInstanceService, IClientFlowInstanc
return AuditFlowCore(info.Status, info.AuditNote, info.Instance);
}
public async Task<DataResult> WithdrawFlowInstanceAsync(long[] ids, string? note = null)
public async Task<DataResult> WithdrawAsync(long[] ids, string? note = null)
{
long userId = long.Parse(User.UserId);
var userInfo = await Db.Queryable<SysUser>().Where(x => x.Id == userId).Select(x => new { x.Id, x.UserName }).FirstAsync();

@ -289,11 +289,6 @@ public class ClientInfoReq
/// </summary>
public string InspectionNo { get; set; }
/// <summary>
/// 审批状态
/// </summary>
public AuditStatusEnum AuditStatus { get; set; } = AuditStatusEnum.Approve;
/// <summary>
/// 审批时间
/// </summary>
@ -373,11 +368,6 @@ public class ClientInfoReq
/// </summary>
public string WMSFeeRateType { get; set; }
/// <summary>
/// 状态 0 启用 1 禁用
/// </summary>
public StatusEnum Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 备注
/// </summary>

@ -288,9 +288,14 @@ public class ClientInfoRes
public string InspectionNo { get; set; }
/// <summary>
/// 审批状态
/// 审批状态
/// </summary>
public AuditStatusEnum AuditStatus { get; set; } = AuditStatusEnum.Approve;
public AuditStatusEnum AuditStatus { get; set; }
/// <summary>
/// 审批状态显示文本
/// </summary>
public string AuditStatusText => AuditStatus.GetDescription();
/// <summary>
/// 审批时间

@ -1,5 +1,7 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Info.Dtos;
namespace DS.WMS.Core.Info.Interface;
@ -9,19 +11,47 @@ namespace DS.WMS.Core.Info.Interface;
/// </summary>
public interface IClientInfoService
{
/// <summary>
/// 提交审核
/// </summary>
/// <param name="idModel"></param>
/// <returns></returns>
Task<DataResult> SubmitAuditAsync(IdModel idModel);
/// <summary>
/// 执行审核
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Task<DataResult> AuditAsync(AuditRequest request);
/// <summary>
/// 撤销审核
/// </summary>
/// <param name="idModel"></param>
/// <returns></returns>
Task<DataResult> WithdrawAsync(IdModel idModel);
/// <summary>
/// 审核完成回调
/// </summary>
/// <param name="callback">回调信息</param>
/// <returns></returns>
Task<DataResult> AuditCallbackAsync(FlowCallback callback);
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<ClientInfoRes>> GetListByPage(PageRequest request);
/// <summary>
/// 编辑
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
DataResult EditClientInfo(ClientInfoReq model);
Task<DataResult> EditClientInfoAsync(ClientInfoReq model);
/// <summary>
/// 获取详情

@ -38,25 +38,24 @@ public class ClientInfoService : ServiceBase, IClientInfoService
/// <summary>
/// 提交审核
/// </summary>
/// <param name="request"></param>
/// <param name="idModel"></param>
/// <returns></returns>
public async Task<DataResult> SubmitAuditAsync(AuditRequest request)
public async Task<DataResult> SubmitAuditAsync(IdModel idModel)
{
var queryable = TenantDb.Queryable<InfoClientContact>().Where(x => request.Ids.Contains(x.ClientId));
var queryable = TenantDb.Queryable<InfoClientContact>().Where(x => idModel.Ids.Contains(x.ClientId));
if (await queryable.AnyAsync(x => (SqlFunc.IsNullOrEmpty(x.Tel) && SqlFunc.IsNullOrEmpty(x.Mobile)) || (SqlFunc.IsNullOrEmpty(x.Email) && SqlFunc.IsNullOrEmpty(x.QQ))))
return DataResult.FailedWithDesc(MultiLanguageConst.ClientInfoIncomplete);
var list = await flowService.Value.GetInstanceByBSIdAsync(AuditType.InfoClient, ids: request.Ids);
if (list.Count > 0)
if (await TenantDb.Queryable<InfoClient>().AnyAsync(x => idModel.Ids.Contains(x.Id) && x.AuditStatus == AuditStatusEnum.Auditing))
return DataResult.FailedWithDesc(MultiLanguageConst.ItemsAreAuditing);
var template = FindTemplateAsync(AuditType.InfoClient);
if (template == null)
return DataResult.FailedWithDesc(MultiLanguageConst.TemplateNotFound);
for (int i = 0; i < request.Ids.Length; i++)
for (int i = 0; i < idModel.Ids.Length; i++)
{
var id = request.Ids[i];
var id = idModel.Ids[i];
var result = flowService.Value.CreateFlowInstance(new CreateFlowInstanceReq
{
BusinessId = id,
@ -70,12 +69,66 @@ public class ClientInfoService : ServiceBase, IClientInfoService
return result;
}
var rows = await TenantDb.Updateable<InfoClient>().Where(x => request.Ids.Contains(x.Id))
var rows = await TenantDb.Updateable<InfoClient>().Where(x => idModel.Ids.Contains(x.Id))
.SetColumns(x => x.AuditStatus == AuditStatusEnum.Auditing).ExecuteCommandAsync();
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(MultiLanguageConst.Operation_Failed);
}
/// <summary>
/// 执行审核
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public async Task<DataResult> AuditAsync(AuditRequest request)
{
var list = await flowService.Value.GetInstanceByBSIdAsync(AuditType.InfoClient, ids: request.Ids);
if (list.Count != request.Ids.Length)
return DataResult.FailedWithDesc(MultiLanguageConst.NotInAudit);
foreach (var item in list)
{
var result = flowService.Value.AuditFlowInstance(new FlowAuditInfo
{
AuditNote = request.Remark,
Status = request.Result,
Instance = item
});
if (!result.Succeeded)
return result;
}
return DataResult.Success;
}
/// <summary>
/// 审核完成回调
/// </summary>
/// <param name="callback">回调信息</param>
/// <returns></returns>
public async Task<DataResult> AuditCallbackAsync(FlowCallback callback)
{
if (callback.Type != AuditType.InfoClient)
return DataResult.FailedWithDesc(MultiLanguageConst.NoAuditItems);
InfoClient infoClient = new()
{
Id = callback.BusinessId,
AuditNote = callback.RejectReason,
AuditTime = DateTime.Now,
AuditStatus = callback.FlowStatus == FlowStatusEnum.Approve ? AuditStatusEnum.Approve : AuditStatusEnum.Reject,
Status = callback.FlowStatus == FlowStatusEnum.Approve ? 0 : 1
};
int rows = await TenantDb.Updateable(infoClient).UpdateColumns(x => new
{
x.AuditNote,
x.AuditTime,
x.AuditStatus,
x.Status
}).ExecuteCommandAsync();
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(MultiLanguageConst.Operation_Failed);
}
/// <summary>
/// 撤销审核
@ -85,10 +138,10 @@ public class ClientInfoService : ServiceBase, IClientInfoService
public async Task<DataResult> WithdrawAsync(IdModel idModel)
{
var list = await flowService.Value.GetInstanceByBSIdAsync(AuditType.InfoClient, ids: idModel.Ids);
if (list.Count == 0)
if (list.Count != idModel.Ids.Length)
return DataResult.FailedWithDesc(MultiLanguageConst.NotInAudit);
var result = await flowService.Value.WithdrawFlowInstanceAsync(idModel.Ids);
var result = await flowService.Value.WithdrawAsync(idModel.Ids);
if (!result.Succeeded)
return result;
@ -132,8 +185,12 @@ public class ClientInfoService : ServiceBase, IClientInfoService
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public DataResult EditClientInfo(ClientInfoReq req)
public async Task<DataResult> EditClientInfoAsync(ClientInfoReq req)
{
var data = req.Adapt<InfoClient>();
data.Status = (int)StatusEnum.Disable;
data.AuditStatus = AuditStatusEnum.NoAudit;
if (req.Id == 0)
{
if (TenantDb.Queryable<InfoClient>().Where(x => (x.ShortName == req.ShortName.Trim() || x.Description == req.Description.Trim() || x.TaxNo == req.TaxNo.Trim())).Any())
@ -141,8 +198,6 @@ public class ClientInfoService : ServiceBase, IClientInfoService
return DataResult.Failed("客户信息已存在,请检查客户全称、简称或社会信用代码是否重复!", MultiLanguageConst.ClientInfoExist);
}
var data = req.Adapt<InfoClient>();
data.AuditStatus = AuditStatusEnum.NoAudit;
var tag = req.ClientTag.Adapt<InfoClientTag>();
//助记码
data.CodeName = PinYinUtil.GetFristLetter(req.ShortName);
@ -153,20 +208,27 @@ public class ClientInfoService : ServiceBase, IClientInfoService
}
else
{
var info = TenantDb.Queryable<InfoClient>().Where(x => x.Id == req.Id).First();
var tag = TenantDb.Queryable<InfoClientTag>().Where(x => x.ClientId == req.Id).First();
info = req.Adapt(info);
var model = await TenantDb.Queryable<InfoClient>().Where(x => x.Id == req.Id).Select(x => new
{
x.Status,
x.AuditStatus
}).FirstAsync();
if (model != null && model.AuditStatus == AuditStatusEnum.Auditing)
return DataResult.FailedWithDesc(MultiLanguageConst.ItemsAreAuditing);
if (TenantDb.Queryable<InfoClient>().Where(x => x.Id != info.Id && (x.ShortName == req.ShortName.Trim() || x.Description == req.Description.Trim() || x.TaxNo == req.TaxNo.Trim())).Any())
var tag = TenantDb.Queryable<InfoClientTag>().Where(x => x.ClientId == req.Id).First();
if (TenantDb.Queryable<InfoClient>().Where(x => x.Id != data.Id && (x.ShortName == req.ShortName.Trim() || x.Description == req.Description.Trim() || x.TaxNo == req.TaxNo.Trim())).Any())
{
return DataResult.Failed("请检查客户全称、简称或社会信用代码是否重复!", MultiLanguageConst.ClientInfoExist);
}
//助记码
info.CodeName = PinYinUtil.GetFristLetter(info.ShortName);
data.CodeName = PinYinUtil.GetFristLetter(data.ShortName);
tag = req.ClientTag.Adapt(tag);
TenantDb.Updateable(info).RemoveDataCache($"{SqlSugarCacheConst.InfoClient}{User.TenantId}").IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
TenantDb.Updateable(data).RemoveDataCache($"{SqlSugarCacheConst.InfoClient}{User.TenantId}")
.IgnoreColumns(ignoreAllNullColumns: true)
.IgnoreColumns(x => new { x.Status, x.AuditStatus })
.EnableDiffLogEvent().ExecuteCommand();
TenantDb.Updateable(tag).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
//创建或更新发票抬头
@ -279,30 +341,6 @@ public class ClientInfoService : ServiceBase, IClientInfoService
}
}
///// <summary>
///// 客户合并
///// </summary>
///// <param name="request"></param>
///// <returns></returns>
//public async Task<DataResult> MergeAsync(ClientMergeRequest request)
//{
// await TenantDb.Ado.BeginTranAsync();
// try
// {
// await TenantDb.Ado.CommitTranAsync();
// return DataResult.Success;
// }
// catch (Exception ex)
// {
// await TenantDb.Ado.RollbackTranAsync();
// await ex.LogAsync(Db);
// return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
// }
//}
#region 获取往来单位详情(含有联系人列表)
/// <summary>

@ -83,10 +83,10 @@ namespace DS.WMS.Core.Op.Entity.TaskInteraction
[SugarColumn(ColumnDescription = "审批驳回理由", Length = 200, IsNullable = true)]
public string? RejectReason { get; set; }
/// <summary>
/// 下一任务配置ID
/// </summary>
[SugarColumn(ColumnDescription = "下一任务配置ID", IsNullable = true)]
public long? NextId { get; set; }
///// <summary>
///// 下一任务配置ID
///// </summary>
//[SugarColumn(ColumnDescription = "下一任务配置ID", IsNullable = true)]
//public long? NextId { get; set; }
}
}

@ -111,7 +111,7 @@ namespace DS.WMS.Core.Op.Entity.TaskInteraction
/// 删除
/// </summary>
[Description("删除")]
Delete = 2,
Delete = 10,
/// <summary>
/// 审核

@ -514,7 +514,8 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
var task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).Select(x => new
{
x.Id,
x.TaskStatus
x.TaskStatus,
x.FlowId
}).FirstAsync();
if (task == null)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData));
@ -522,7 +523,44 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
if (task.TaskStatus == TaskStatusEnum.Complete)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCompleted));
return await Delete(request.BusinessId, request.BusinessType, "用户撤销审核", request.TaskType);
if (!task.FlowId.HasValue)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NotInFlows));
DateTime dt = DateTime.Now;
await TenantDb.Ado.BeginTranAsync();
try
{
var result = await ManagerService.SetTaskStatus(request.BusinessId, request.TaskType, TaskStatusEnum.Cancel, dt);
if (!result.Succeeded)
return result;
result = await FlowService.Value.WithdrawAsync([task.FlowId.Value], "用户撤销审核");
if (!result.Succeeded)
return result;
await TenantDb.Updateable<BusinessTask>().Where(x => x.Id == task.Id).SetColumns(
x => x.TaskStatus == TaskStatusEnum.Cancel).ExecuteCommandAsync();
await LogService.WriteLogAsync(new BusinessTaskLog
{
ActionType = ActionType.StatusChanged,
AuditStatus = FlowStatusEnum.Draft,
BusinessId = request.BusinessId,
BusinessType = request.BusinessType,
CreateBy = long.Parse(User.UserId),
CreateTime = dt,
TaskStatus = TaskStatusEnum.Cancel,
TaskType = request.TaskType
});
await TenantDb.Ado.CommitTranAsync();
return DataResult.Success;
}
catch (Exception ex)
{
await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db);
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}
/// <summary>

@ -5,6 +5,8 @@ using DS.WMS.Core.Info.Dtos;
using DS.WMS.Core.Info.Interface;
using Microsoft.AspNetCore.Mvc;
using Masuit.Tools.Systems;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Flow.Dtos;
namespace DS.WMS.MainApi.Controllers;
@ -24,6 +26,59 @@ public class ClientInfoController : ApiController
_invokeService = invokeService;
}
/// <summary>
/// 提交审核
/// </summary>
/// <param name="idModel"></param>
/// <returns></returns>
[HttpPost, Route("SubmitAudit")]
public async Task<DataResult> SubmitAuditAsync([FromBody] IdModel idModel)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage());
return await _invokeService.SubmitAuditAsync(idModel);
}
/// <summary>
/// 执行审核
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("Audit")]
public async Task<DataResult> AuditAsync([FromBody] AuditRequest request)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage());
return await _invokeService.AuditAsync(request);
}
/// <summary>
/// 撤销审核
/// </summary>
/// <param name="idModel"></param>
/// <returns></returns>
[HttpPost, Route("Withdraw")]
public async Task<DataResult> WithdrawAsync([FromBody] IdModel idModel)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage());
return await _invokeService.SubmitAuditAsync(idModel);
}
/// <summary>
/// 审核完成回调
/// </summary>
/// <param name="callback">回调信息</param>
/// <returns></returns>
[HttpPost, Route("AuditCallback")]
public async Task<DataResult> AuditCallbackAsync(FlowCallback callback)
{
return await _invokeService.AuditCallbackAsync(callback);
}
/// <summary>
/// 列表
/// </summary>
@ -42,11 +97,10 @@ public class ClientInfoController : ApiController
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
[Route("EditClientInfo")]
public DataResult EditClientInfo([FromBody] ClientInfoReq req)
[HttpPost, Route("EditClientInfo")]
public async Task<DataResult> EditClientInfoAsync([FromBody] ClientInfoReq req)
{
var res = _invokeService.EditClientInfo(req);
var res = await _invokeService.EditClientInfoAsync(req);
return res;
}
@ -69,7 +123,7 @@ public class ClientInfoController : ApiController
/// <param name="idModel"></param>
/// <returns></returns>
[HttpPost, Route("DeleteInvoiceHeader")]
public async Task<DataResult> DeleteInvoiceHeaderAsync(IdModel idModel)
public async Task<DataResult> DeleteInvoiceHeaderAsync(IdModel idModel)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);

Loading…
Cancel
Save