费用修改审核

usertest
嵇文龙 5 months ago
parent 7864b355b4
commit 88986e6c57

@ -89,6 +89,12 @@ namespace DS.Module.Core
/// 申请删除
/// </summary>
[Description("申请删除")]
ApplyDeletion
ApplyDeletion,
/// <summary>
/// 整单审核
/// </summary>
[Description("整单审核")]
Business
}
}

@ -7,6 +7,9 @@ namespace DS.WMS.Core.Fee.Entity
[SugarTable("fee_modification", TableDescription = "费用修改记录")]
public class FeeModification : BaseModel<long>
{
/// <summary>
/// 费用记录ID
/// </summary>
[SugarColumn(ColumnDescription = "费用记录ID")]
public long FeeRecordId { get; set; }
@ -335,11 +338,6 @@ namespace DS.WMS.Core.Fee.Entity
[SugarColumn(ColumnDescription = "发票自助连接", IsNullable = true, Length = 50)]
public string InvLinkId { get; set; }
/// <summary>
/// 是否完成
/// </summary>
[SugarColumn(ColumnDescription = "是否完成", DefaultValue = "0")]
public bool IsFinished { get; set; }
}
}

@ -59,6 +59,13 @@ public interface IFeeRecordService
/// <returns></returns>
DataResult SubmitForApproval(FeeAuditType auditType, params long[] idArray);
/// <summary>
/// 发起费用修改申请
/// </summary>
/// <param name="items">费用修改信息</param>
/// <returns></returns>
DataResult SubmitForModification(IEnumerable<FeeModification> items);
/// <summary>
/// 撤销审批
/// </summary>

@ -1,4 +1,5 @@
using System.Text;
using AngleSharp.Dom;
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.SqlSugar;
@ -311,7 +312,7 @@ namespace DS.WMS.Core.Fee.Method
}
/// <summary>
/// 发起审批工作流
/// 发起审批/申请删除工作流
/// </summary>
/// <param name="auditType">审批类型</param>
/// <param name="idArray">费用记录ID</param>
@ -340,7 +341,7 @@ namespace DS.WMS.Core.Fee.Method
if (fees.Any(x => x.FeeStatus == FeeStatus.PartialSettlement || x.FeeStatus == FeeStatus.SettlementCompleted))
return DataResult.Failed($"当前审批费用包含已结算/部分结算的费用,无法提交", MultiLanguageConst.Operation_Failed);
DataResult result = null;
DataResult result = DataResult.Failed(string.Empty, MultiLanguageConst.Operation_Failed);
tenantDb.Ado.BeginTran();
try
{
@ -348,10 +349,6 @@ namespace DS.WMS.Core.Fee.Method
{
result = ApplyAudit(tenantDb, fees);
}
else if (auditType == FeeAuditType.ApplyModification)
{
ApplyModify(tenantDb, fees);
}
else if (auditType == FeeAuditType.ApplyDeletion)
{
result = ApplyDelete(tenantDb, fees);
@ -421,8 +418,8 @@ namespace DS.WMS.Core.Fee.Method
return DataResult.Success;
}
//审核通过->申请修改
DataResult ApplyModify(SqlSugarScopeProvider tenantDb, List<FeeRecord> fees)
//审核通过->申请删除
DataResult ApplyDelete(SqlSugarScopeProvider tenantDb, List<FeeRecord> fees)
{
StringBuilder sb = new StringBuilder();
foreach (var fe in fees)
@ -436,11 +433,10 @@ namespace DS.WMS.Core.Fee.Method
if (sb.Length > 0)
return DataResult.Failed(sb.ToString(), MultiLanguageConst.Operation_Failed);
var template = FindTemplate(FeeAuditType.ApplyModification.ToString());
var template = FindTemplate(FeeAuditType.ApplyDeletion.ToString());
if (template == null)
return DataResult.Failed("未能找到审批模板", MultiLanguageConst.Operation_Failed);
List<FeeModification> list = new List<FeeModification>(fees.Count);
DateTime dtNow = DateTime.Now;
foreach (var item in fees)
{
@ -450,27 +446,33 @@ namespace DS.WMS.Core.Fee.Method
var instance = result.Data as FlowInstance;
flowService.StartFlowInstance(instance.Id.ToString());
//变更状态为申请修改
item.FeeStatus = FeeStatus.ApplyModification;
//变更状态为申请删除
item.FeeStatus = FeeStatus.ApplyDeletion;
item.SubmitBy = long.Parse(user.UserId);
item.SubmitDate = dtNow;
item.FlowId = instance.Id;
FeeModification modification = item.Adapt<FeeModification>();
modification.Id = 0;
modification.FeeRecordId = item.Id;
list.Add(modification);
}
}
tenantDb.Insertable(list).ExecuteCommand();
return DataResult.Success;
}
//审核通过->申请删除
DataResult ApplyDelete(SqlSugarScopeProvider tenantDb, List<FeeRecord> fees)
/// <summary>
/// 发起费用修改申请
/// </summary>
/// <param name="items">费用修改信息</param>
/// <returns></returns>
public DataResult SubmitForModification(IEnumerable<FeeModification> items)
{
var idList = items.Select(x => x.FeeRecordId).Distinct().ToList();
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var fees = tenantDb.Queryable<FeeRecord>().Select(x => new FeeRecord
{
Id = x.Id,
FeeName = x.FeeName,
FeeStatus = x.FeeStatus
}).ToList();
StringBuilder sb = new StringBuilder();
foreach (var fe in fees)
{
@ -483,28 +485,42 @@ namespace DS.WMS.Core.Fee.Method
if (sb.Length > 0)
return DataResult.Failed(sb.ToString(), MultiLanguageConst.Operation_Failed);
var template = FindTemplate(FeeAuditType.ApplyDeletion.ToString());
var template = FindTemplate(FeeAuditType.ApplyModification.ToString());
if (template == null)
return DataResult.Failed("未能找到审批模板", MultiLanguageConst.Operation_Failed);
DateTime dtNow = DateTime.Now;
foreach (var item in fees)
tenantDb.Ado.BeginTran();
try
{
var result = flowService.CreateFlowInstance(new CreateFlowInstanceReq { BusinessId = item.Id, TemplateId = template.Id });
if (result.Succeeded)
foreach (var fee in fees)
{
var instance = result.Data as FlowInstance;
flowService.StartFlowInstance(instance.Id.ToString());
//变更状态为申请删除
item.FeeStatus = FeeStatus.ApplyDeletion;
item.SubmitBy = long.Parse(user.UserId);
item.SubmitDate = dtNow;
item.FlowId = instance.Id;
var result = flowService.CreateFlowInstance(new CreateFlowInstanceReq { BusinessId = fee.Id, TemplateId = template.Id });
if (result.Succeeded)
{
var instance = result.Data as FlowInstance;
flowService.StartFlowInstance(instance.Id.ToString());
//变更状态为申请修改
fee.FeeStatus = FeeStatus.ApplyModification;
fee.SubmitBy = long.Parse(user.UserId);
fee.SubmitDate = dtNow;
fee.FlowId = instance.Id;
}
}
}
return DataResult.Success;
tenantDb.Insertable<FeeModification>(items).ExecuteCommand();
tenantDb.Updateable<FeeRecord>(fees).UpdateColumns(x => new { x.FeeStatus, x.FlowId }).ExecuteCommand();
tenantDb.Ado.CommitTran();
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
}
catch (Exception ex)
{
tenantDb.Ado.RollbackTran();
//todo:记录错误日志
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
}
}
/// <summary>
@ -515,15 +531,12 @@ namespace DS.WMS.Core.Fee.Method
public DataResult UpdateAuditStatus(FlowCallback callback)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var fee = tenantDb.Queryable<FeeRecord>().Where(x => x.Id == callback.BusinessId).Select(x => new { x.Id, x.FeeStatus }).First();
var fee = tenantDb.Queryable<FeeRecord>().Where(x => x.Id == callback.BusinessId).Select(
x => new FeeRecord { Id = x.Id, FeeStatus = x.FeeStatus }).First();
if (fee == null)
return DataResult.Failed("未能找到费用记录,更新状态失败", MultiLanguageConst.Operation_Failed);
var entity = new FeeRecord
{
Id = fee.Id,
Reason = callback.RejectReason
};
fee.Reason = callback.RejectReason;
var auditType = callback.AuditType.ToEnum<FeeAuditType>();
tenantDb.Ado.BeginTran();
try
@ -531,62 +544,80 @@ namespace DS.WMS.Core.Fee.Method
switch (auditType)
{
case FeeAuditType.ApplyAudit:
entity.AuditBy = long.Parse(user.UserId);
entity.AuditDate = DateTime.Now;
fee.AuditBy = long.Parse(user.UserId);
fee.AuditDate = DateTime.Now;
if (callback.FlowStatus == FlowStatusEnum.Approve)
{
entity.FeeStatus = FeeStatus.AuditPassed;
entity.Reason = string.Empty;
fee.FeeStatus = FeeStatus.AuditPassed;
fee.Reason = string.Empty;
}
else if (callback.FlowStatus == FlowStatusEnum.Reject)
entity.FeeStatus = FeeStatus.RejectSubmission;
fee.FeeStatus = FeeStatus.RejectSubmission;
tenantDb.Updateable(entity).UpdateColumns(x => new
tenantDb.Updateable(fee).UpdateColumns(x => new
{
x.Id,
x.FeeStatus,
x.AuditBy,
x.AuditDate,
x.Reason,
x.FlowId
}).ExecuteCommand();
break;
case FeeAuditType.ApplyModification:
//申请修改审核成功需要回填费用信息
if (callback.FlowStatus == FlowStatusEnum.Approve)
{
entity.FeeStatus = FeeStatus.AuditPassed;
entity.Reason = string.Empty;
fee.FeeStatus = FeeStatus.AuditPassed;
fee.Reason = string.Empty;
var fm = tenantDb.Queryable<FeeModification>().Where(x => x.FeeRecordId == fee.Id).OrderByDescending(x => x.CreateTime).First();
if (fm == null)
return DataResult.Failed("未找到费用修改信息,更新失败", MultiLanguageConst.Operation_Failed);
var entity = fm.Adapt<FeeRecord>();
entity.FeeStatus = FeeStatus.AuditPassed;
entity.Reason = callback.RejectReason;
fee = entity;
fm.Deleted = true;
fm.DeleteTime = DateTime.Now;
fm.DeleteBy = long.Parse(user.UserId);
tenantDb.Updateable(fm).UpdateColumns(x => new
{
x.Id,
x.DeleteBy,
x.Deleted,
x.DeleteTime
}).ExecuteCommand();
}
else if (callback.FlowStatus == FlowStatusEnum.Reject)
entity.FeeStatus = FeeStatus.RejectApplication;
fee.FeeStatus = FeeStatus.RejectApplication;
tenantDb.Updateable(entity).UpdateColumns(x => new
tenantDb.Updateable(fee).UpdateColumns(x => new
{
x.Id,
x.FeeStatus,
x.AuditBy,
x.AuditDate,
x.Reason,
x.FlowId
}).ExecuteCommand();
break;
case FeeAuditType.ApplyDeletion:
if (callback.FlowStatus == FlowStatusEnum.Approve)
{
tenantDb.Deleteable(entity).ExecuteCommand();
tenantDb.Deleteable(fee).ExecuteCommand();
}
else
{
entity.FeeStatus = FeeStatus.RejectApplication;
fee.FeeStatus = FeeStatus.RejectApplication;
tenantDb.Updateable(entity).UpdateColumns(x => new
tenantDb.Updateable(fee).UpdateColumns(x => new
{
x.Id,
x.FeeStatus,
x.AuditBy,
x.AuditDate,
x.Reason,
x.FlowId
}).ExecuteCommand();
}
@ -613,6 +644,7 @@ namespace DS.WMS.Core.Fee.Method
catch (Exception)
{
tenantDb.Ado.RollbackTran();
//todo:记录错误日志
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
}
}
@ -644,12 +676,12 @@ namespace DS.WMS.Core.Fee.Method
return DataResult.Failed($"以下费用项:{msg} 未在审批状态中,无需撤销", MultiLanguageConst.Operation_Failed);
}
var flows = fees.Select(x => new FlowInstance { Id = x.FlowId.Value });
var flows = fees.Select(x => new FlowInstance { Id = x.FlowId.Value, FlowStatus = (int)FlowStatusEnum.Draft, MakerList = string.Empty });
DateTime dtNow = DateTime.Now;
try
{
tenantDb.Ado.BeginTran();
tenantDb.Deleteable<FlowInstance>(flows).ExecuteCommand();
tenantDb.Updateable<FlowInstance>(flows).UpdateColumns(x => new { x.FlowStatus, x.MakerList }).ExecuteCommand();
foreach (var item in fees)
{
@ -685,6 +717,16 @@ namespace DS.WMS.Core.Fee.Method
}
/// <summary>
/// 整单审核
/// </summary>
/// <param name="bid">业务ID</param>
/// <returns></returns>
//public DataResult AuditBusiness(int type, long bid)
//{
//}
/// <summary>
/// 查找模板
/// </summary>

@ -904,13 +904,14 @@ public class FlowRuntime
}
else
{
forkNode.SetInfo.ConfluenceOk++;
if (forkNode.SetInfo.ConfluenceOk == forkNumber) //会签成功
{
res = nextNode.Id;
}
else
{
forkNode.SetInfo.ConfluenceOk++;
//同一节点的会签未达到所有审核人同意时节点类型设置为5
NextNodeType = 5;
res = nodeId;

@ -1,12 +1,12 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Flow.Interface;
using Mapster;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.FeeApi.Controllers
@ -141,18 +141,16 @@ namespace DS.WMS.FeeApi.Controllers
/// <summary>
/// 申请修改
/// </summary>
/// <param name="model">费用记录ID</param>
/// <param name="items">费用修改信息</param>
/// <returns></returns>
//[HttpPost, Route("ApplyModification")]
//public DataResult ApplyModification([FromBody] IdModel model)
//{
// if (model == null || model.Ids.Length == 0)
// return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
//}
[HttpPost, Route("ApplyModification")]
public DataResult ApplyModification([FromBody] IEnumerable<FeeModification> items)
{
if (items.IsNullOrEmpty())
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return _feeService.SubmitForModification(items);
}
/// <summary>
/// 撤销审批申请

@ -712,3 +712,17 @@
2024-05-28 17:56:37.4269 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config
2024-05-28 17:56:37.4269 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-05-28 17:56:37.4419 Info Configuration initialized.
2024-05-29 08:46:16.2558 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-05-29 08:46:16.2558 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-05-29 08:46:16.2747 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-05-29 08:46:16.2873 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-05-29 08:46:16.2873 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config
2024-05-29 08:46:16.2873 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-05-29 08:46:16.2873 Info Configuration initialized.
2024-05-29 09:24:06.1039 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-05-29 09:24:06.1229 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-05-29 09:24:06.1286 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-05-29 09:24:06.1448 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-05-29 09:24:06.1448 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config
2024-05-29 09:24:06.1448 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-05-29 09:24:06.1575 Info Configuration initialized.

@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project>
<PropertyGroup>
<_PublishTargetUrl>D:\Publish\DS8\FeeApi</_PublishTargetUrl>
<History>True|2024-05-28T00:44:31.4427261Z||;False|2024-05-28T08:44:02.5254826+08:00||;True|2024-05-27T15:16:32.9413631+08:00||;True|2024-05-27T15:03:42.9803879+08:00||;True|2024-05-27T08:49:54.3933663+08:00||;True|2024-05-27T08:46:13.5862236+08:00||;True|2024-05-23T17:19:32.8154451+08:00||;True|2024-05-23T17:19:01.4587615+08:00||;True|2024-05-22T16:52:42.2166228+08:00||;True|2024-05-22T15:19:49.1773202+08:00||;True|2024-05-22T15:13:31.9485525+08:00||;True|2024-05-22T13:29:02.1355808+08:00||;True|2024-05-22T09:48:40.8753914+08:00||;True|2024-05-22T09:25:06.2068137+08:00||;True|2024-05-22T09:18:53.0759815+08:00||;True|2024-05-21T17:13:36.4091775+08:00||;True|2024-05-21T14:41:18.8486299+08:00||;True|2024-05-21T11:04:27.3649637+08:00||;</History>
<History>True|2024-05-29T00:36:28.9569161Z||;True|2024-05-28T08:44:31.4427261+08:00||;False|2024-05-28T08:44:02.5254826+08:00||;True|2024-05-27T15:16:32.9413631+08:00||;True|2024-05-27T15:03:42.9803879+08:00||;True|2024-05-27T08:49:54.3933663+08:00||;True|2024-05-27T08:46:13.5862236+08:00||;True|2024-05-23T17:19:32.8154451+08:00||;True|2024-05-23T17:19:01.4587615+08:00||;True|2024-05-22T16:52:42.2166228+08:00||;True|2024-05-22T15:19:49.1773202+08:00||;True|2024-05-22T15:13:31.9485525+08:00||;True|2024-05-22T13:29:02.1355808+08:00||;True|2024-05-22T09:48:40.8753914+08:00||;True|2024-05-22T09:25:06.2068137+08:00||;True|2024-05-22T09:18:53.0759815+08:00||;True|2024-05-21T17:13:36.4091775+08:00||;True|2024-05-21T14:41:18.8486299+08:00||;True|2024-05-21T11:04:27.3649637+08:00||;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

@ -1548,3 +1548,17 @@
2024-05-28 17:56:38.0263 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-05-28 17:56:38.0356 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-05-28 17:56:38.0356 Info Configuration initialized.
2024-05-29 08:46:16.6953 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-05-29 08:46:16.7108 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-05-29 08:46:16.7108 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-05-29 08:46:16.7298 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-05-29 08:46:16.7298 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-05-29 08:46:16.7389 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-05-29 08:46:16.7389 Info Configuration initialized.
2024-05-29 09:24:06.7697 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-05-29 09:24:06.7917 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-05-29 09:24:06.7971 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-05-29 09:24:06.8138 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-05-29 09:24:06.8138 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-05-29 09:24:06.8138 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-05-29 09:24:06.8317 Info Configuration initialized.

@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project>
<PropertyGroup>
<_PublishTargetUrl>D:\Publish\DS8\Main</_PublishTargetUrl>
<History>True|2024-05-28T00:47:53.8630073Z||;True|2024-05-23T17:51:45.6784172+08:00||;True|2024-05-21T17:32:52.9294009+08:00||;</History>
<History>True|2024-05-28T10:00:39.2399003Z||;True|2024-05-28T08:47:53.8630073+08:00||;True|2024-05-23T17:51:45.6784172+08:00||;True|2024-05-21T17:32:52.9294009+08:00||;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
Loading…
Cancel
Save