|
|
|
@ -10,6 +10,7 @@ using DS.WMS.Core.Flow.Entity;
|
|
|
|
|
using DS.WMS.Core.Flow.Interface;
|
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
@ -22,7 +23,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
{
|
|
|
|
|
//待审核的状态值
|
|
|
|
|
public static readonly FeeStatus[] AuditStatusArray = [FeeStatus.AuditSubmitted, FeeStatus.ApplyDeletion, FeeStatus.ApplyModification];
|
|
|
|
|
public int RunningStatus = (int)FlowStatusEnum.Running;
|
|
|
|
|
public static readonly int RunningStatus = (int)FlowStatusEnum.Running;
|
|
|
|
|
|
|
|
|
|
readonly IServiceProvider _serviceProvider;
|
|
|
|
|
readonly ISqlSugarClient db;
|
|
|
|
@ -152,9 +153,9 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 批量审批
|
|
|
|
|
/// 批量费用审批
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="yesOrNo">审批结果</param>
|
|
|
|
|
/// <param name="yesOrNo">审批结果:1=通过,2=驳回</param>
|
|
|
|
|
/// <param name="remark">备注</param>
|
|
|
|
|
/// <param name="idArray">待审批的费用ID</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
@ -170,10 +171,10 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
if (fees.Count == 0)
|
|
|
|
|
return DataResult.Failed("未能获取费用信息,提交失败");
|
|
|
|
|
return DataResult.Failed("未能获取费用信息");
|
|
|
|
|
|
|
|
|
|
if (fees.Exists(x => !x.FlowId.HasValue))
|
|
|
|
|
return DataResult.Failed("提交数据中包含未在审批状态的费用");
|
|
|
|
|
return DataResult.Failed("提交数据中包含不在审批流程中的费用");
|
|
|
|
|
|
|
|
|
|
if (fees.Exists(x => !AuditStatusArray.Contains(x.FeeStatus)))
|
|
|
|
|
return DataResult.Failed("提交数据中包含不在待审批状态的费用");
|
|
|
|
@ -223,6 +224,256 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 整单审批
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="yesOrNo">审批结果:1=通过,2=驳回</param>
|
|
|
|
|
/// <param name="remark">备注</param>
|
|
|
|
|
/// <param name="id">业务ID</param>
|
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult AuditBusiness(int yesOrNo, string remark, long id, BusinessType businessType)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
var biz = tenantDb.Queryable<BusinessFeeStatus>().Where(x => x.BusinessId == id && x.BusinessType == businessType)
|
|
|
|
|
.Select(x => new
|
|
|
|
|
{
|
|
|
|
|
x.Id,
|
|
|
|
|
x.BillAuditStatus,
|
|
|
|
|
x.FlowId
|
|
|
|
|
}).First();
|
|
|
|
|
|
|
|
|
|
if (biz == null)
|
|
|
|
|
return DataResult.Failed("未能获取业务信息");
|
|
|
|
|
|
|
|
|
|
if (!biz.FlowId.HasValue)
|
|
|
|
|
return DataResult.Failed("业务未处于审批流程中");
|
|
|
|
|
|
|
|
|
|
if (biz.BillAuditStatus != BillAuditStatus.AuditSubmitted)
|
|
|
|
|
return DataResult.Failed("业务的审批状态不正确");
|
|
|
|
|
|
|
|
|
|
var flow = db.Queryable<FlowInstance>().Where(x => x.Id == biz.FlowId.Value).Select(x => new
|
|
|
|
|
{
|
|
|
|
|
x.Id,
|
|
|
|
|
x.ActivityId,
|
|
|
|
|
x.BusinessId,
|
|
|
|
|
x.BusinessType,
|
|
|
|
|
x.MakerList
|
|
|
|
|
}).First();
|
|
|
|
|
|
|
|
|
|
if (flow == null)
|
|
|
|
|
return DataResult.Failed("未能获取审批工作流");
|
|
|
|
|
|
|
|
|
|
if (!flow.MakerList.Contains(user.UserId))
|
|
|
|
|
return DataResult.Failed("所选费用包含不属于当前用户权限范围内的审批,禁止提交");
|
|
|
|
|
|
|
|
|
|
var result = flowService.AuditFlowInstance(new FlowInstanceAuditReq
|
|
|
|
|
{
|
|
|
|
|
Id = flow.Id,
|
|
|
|
|
NodeId = flow.ActivityId,
|
|
|
|
|
Status = yesOrNo,
|
|
|
|
|
AuditNote = remark
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据审批结果更新审批状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="callback">回调信息</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult UpdateAuditStatus(FlowCallback callback)
|
|
|
|
|
{
|
|
|
|
|
var auditType = callback.AuditType.ToEnum<FeeAuditType>();
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
FeeRecord fee = null;
|
|
|
|
|
BusinessFeeStatus businessFee = null;
|
|
|
|
|
if (auditType == FeeAuditType.Business)
|
|
|
|
|
{
|
|
|
|
|
businessFee = tenantDb.Queryable<BusinessFeeStatus>().Where(x => x.Id == callback.BusinessId && x.BusinessType == callback.BusinessType)
|
|
|
|
|
.Select(x => new BusinessFeeStatus
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
BusinessId = x.BusinessId,
|
|
|
|
|
BillAuditStatus = x.BillAuditStatus
|
|
|
|
|
}).First();
|
|
|
|
|
if (businessFee == null)
|
|
|
|
|
return DataResult.Failed("未能找到业务信息,更新状态失败", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fee = tenantDb.Queryable<FeeRecord>().Where(x => x.Id == callback.BusinessId && x.BusinessType == callback.BusinessType).Select(
|
|
|
|
|
x => new FeeRecord { Id = x.Id, FeeStatus = x.FeeStatus }).First();
|
|
|
|
|
if (fee == null)
|
|
|
|
|
return DataResult.Failed("未能找到费用记录,更新状态失败", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
|
|
|
|
|
fee.Reason = callback.RejectReason;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long userId = long.Parse(user.UserId);
|
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
|
tenantDb.Ado.BeginTran();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
switch (auditType)
|
|
|
|
|
{
|
|
|
|
|
case FeeAuditType.ApplyAudit:
|
|
|
|
|
fee.AuditBy = userId;
|
|
|
|
|
fee.AuditOperator = user.UserName;
|
|
|
|
|
fee.AuditDate = dtNow;
|
|
|
|
|
|
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Approve)
|
|
|
|
|
{
|
|
|
|
|
fee.FeeStatus = FeeStatus.AuditPassed;
|
|
|
|
|
fee.Reason = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
else if (callback.FlowStatus == FlowStatusEnum.Reject)
|
|
|
|
|
fee.FeeStatus = FeeStatus.RejectSubmission;
|
|
|
|
|
|
|
|
|
|
tenantDb.Updateable(fee).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.FeeStatus,
|
|
|
|
|
x.AuditBy,
|
|
|
|
|
x.AuditOperator,
|
|
|
|
|
x.AuditDate,
|
|
|
|
|
x.Reason,
|
|
|
|
|
x.FlowId
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FeeAuditType.ApplyModification:
|
|
|
|
|
//申请修改审核成功需要回填费用信息
|
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Approve)
|
|
|
|
|
{
|
|
|
|
|
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.Id = fm.FeeRecordId;
|
|
|
|
|
entity.FeeStatus = FeeStatus.AuditPassed;
|
|
|
|
|
entity.Reason = callback.RejectReason;
|
|
|
|
|
entity.UpdateBy = userId;
|
|
|
|
|
entity.UpdateTime = dtNow;
|
|
|
|
|
//全表更新
|
|
|
|
|
tenantDb.Updateable(entity).IgnoreColumns(
|
|
|
|
|
x => new { x.AuditBy, x.AuditDate, x.AuditOperator, x.SubmitBy, x.SubmitDate }).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
//逻辑删除暂存数据
|
|
|
|
|
fm.Deleted = true;
|
|
|
|
|
fm.DeleteTime = dtNow;
|
|
|
|
|
fm.DeleteBy = userId;
|
|
|
|
|
tenantDb.Updateable(fm).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.DeleteBy,
|
|
|
|
|
x.Deleted,
|
|
|
|
|
x.DeleteTime
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
else if (callback.FlowStatus == FlowStatusEnum.Reject)
|
|
|
|
|
{
|
|
|
|
|
fee.FeeStatus = FeeStatus.RejectApplication;
|
|
|
|
|
tenantDb.Updateable(fee).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.FeeStatus,
|
|
|
|
|
x.Reason,
|
|
|
|
|
x.FlowId
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FeeAuditType.ApplyDeletion:
|
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Approve)
|
|
|
|
|
{
|
|
|
|
|
fee.Deleted = true;
|
|
|
|
|
fee.DeleteBy = userId;
|
|
|
|
|
fee.DeleteTime = dtNow;
|
|
|
|
|
|
|
|
|
|
tenantDb.Updateable(fee).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.DeleteBy,
|
|
|
|
|
x.Deleted,
|
|
|
|
|
x.DeleteTime,
|
|
|
|
|
x.Reason,
|
|
|
|
|
x.FlowId
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
//tenantDb.Deleteable(fee).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fee.FeeStatus = FeeStatus.RejectApplication;
|
|
|
|
|
|
|
|
|
|
tenantDb.Updateable(fee).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.FeeStatus,
|
|
|
|
|
x.Reason,
|
|
|
|
|
x.FlowId
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FeeAuditType.Business:
|
|
|
|
|
FeeStatus status = FeeStatus.RejectSubmission;
|
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Approve)
|
|
|
|
|
{
|
|
|
|
|
businessFee.BillAuditStatus = BillAuditStatus.AuditPassed;
|
|
|
|
|
status = FeeStatus.AuditPassed;
|
|
|
|
|
}
|
|
|
|
|
else if (callback.FlowStatus == FlowStatusEnum.Reject)
|
|
|
|
|
{
|
|
|
|
|
businessFee.BillAuditStatus = BillAuditStatus.Rejected;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tenantDb.Updateable(businessFee).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.BillAuditStatus,
|
|
|
|
|
x.FlowId
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tenantDb.Updateable<FeeRecord>()
|
|
|
|
|
.SetColumns(x => x.FeeStatus == status)
|
|
|
|
|
.SetColumns(x => x.FlowId == null)
|
|
|
|
|
.SetColumns(x => x.AuditBy == userId)
|
|
|
|
|
.SetColumns(x => x.AuditOperator == user.UserName)
|
|
|
|
|
.SetColumns(x => x.AuditDate == dtNow)
|
|
|
|
|
.Where(x => x.BusinessId == businessFee.BusinessId && x.BusinessType == callback.BusinessType &&
|
|
|
|
|
(x.FeeStatus == FeeStatus.Entering || x.FeeStatus == FeeStatus.RejectSubmission)).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return DataResult.Failed("费用未处于审批状态,更新失败", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//驳回申请则逻辑删除关联工作流
|
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Reject)
|
|
|
|
|
{
|
|
|
|
|
db.Updateable(new FlowInstance
|
|
|
|
|
{
|
|
|
|
|
Id = callback.InstanceId,
|
|
|
|
|
Deleted = true,
|
|
|
|
|
DeleteBy = long.Parse(user.UserId),
|
|
|
|
|
DeleteTime = DateTime.Now
|
|
|
|
|
}).UpdateColumns(x => new { x.Deleted, x.DeleteBy, x.DeleteTime }).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tenantDb.Ado.CommitTran();
|
|
|
|
|
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
tenantDb.Ado.RollbackTran();
|
|
|
|
|
ex.Log(db);
|
|
|
|
|
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
FeeRecordService.WriteBackStatus(tenantDb, callback.BusinessId, callback.BusinessType);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//public DataResult<List<FeeAudit>> GetListByPage(PageRequest request)
|
|
|
|
|