zhangxiaofeng 2 months ago
commit 9da3b4f3d4

@ -44,4 +44,12 @@ public interface IDataRuleTemplateService
/// <returns></returns> /// <returns></returns>
Task<DataResult<List<CodeDataRuleTemplateRes>>> GetDataRuleTemplateSelectList(string id, string ruleType); Task<DataResult<List<CodeDataRuleTemplateRes>>> GetDataRuleTemplateSelectList(string id, string ruleType);
/// <summary>
/// 数据权限模板复制
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public Task<DataResult> BatchCopyDataRuleTemplate(IdModel req);
} }

@ -127,5 +127,25 @@ namespace DS.WMS.Core.Code.Method
} }
return await Task.FromResult(DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess)); return await Task.FromResult(DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess));
} }
public async Task<DataResult> BatchCopyDataRuleTemplate(IdModel req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = await tenantDb.Queryable<CodeDataRuleTemplate>().Where(x => req.Ids.Contains(x.Id)).ToListAsync();
var newList = new List<CodeDataRuleTemplate>();
if (list.Count > 0)
{
foreach (var item in list) {
var temp = item.Adapt<CodeDataRuleTemplate>();
temp.Id = 0;
temp.TemplateName = item.TemplateName +"-复制";
newList.Add(temp);
}
await tenantDb.Insertable(newList).ExecuteCommandAsync();
}
return await Task.FromResult(DataResult.Successed("复制成功!", MultiLanguageConst.DataCopySuccess));
}
} }
} }

@ -0,0 +1,48 @@
using DS.Module.Core;
using DS.Module.UserModule;
using DS.WMS.Core.Op.Entity;
using SqlSugar;
namespace DS.WMS.Core.Fee.Dtos
{
/// <summary>
/// 报表生成上下文
/// </summary>
public class ReportContext
{
/// <summary>
/// 服务提供程序
/// </summary>
public IServiceProvider ServiceProvider { get; internal set; }
/// <summary>
/// 获取主库访问对象
/// </summary>
public ISqlSugarClient Db { get; internal set; }
/// <summary>
/// 获取租户库访问对象
/// </summary>
public ISqlSugarClient TenantDb { get; internal set; }
/// <summary>
/// 请求用户
/// </summary>
public IUser User { get; internal set; }
/// <summary>
/// 操作结果,用于记录错误信息
/// </summary>
public DataResult? ErrorResult { get; set; }
/// <summary>
/// 业务类型
/// </summary>
public BusinessType BusinessType { get; set; } = BusinessType.OceanShippingExport;
/// <summary>
/// 业务ID
/// </summary>
public long[] Ids { get; set; } = [];
}
}

@ -96,12 +96,13 @@ public interface IFeeRecordService
Task WriteBackStatusAsync(long businessId, BusinessType businessType); Task WriteBackStatusAsync(long businessId, BusinessType businessType);
/// <summary> /// <summary>
/// 获取费用核算单打印信息 /// 获取费用打印信息
/// </summary> /// </summary>
/// <param name="providerName">数据提供程序</param>
/// <param name="businessType">业务类型</param> /// <param name="businessType">业务类型</param>
/// <param name="idArray">费用记录ID</param> /// <param name="idArray">费用记录ID</param>
/// <returns></returns> /// <returns></returns>
Task<DataResult<CostAccountingForm>> GetPrintInfoAsync(BusinessType businessType, params long[] idArray); Task<DataResult<dynamic>> GetPrintInfoAsync(string providerName, BusinessType businessType, params long[] idArray);
/// <summary> /// <summary>
/// 设置发票启用状态 /// 设置发票启用状态

@ -0,0 +1,17 @@
using DS.WMS.Core.Fee.Dtos;
namespace DS.WMS.Core.Fee.Interface
{
/// <summary>
/// 用于输出报表的数据提供程序
/// </summary>
public interface IReportProvider
{
/// <summary>
/// 返回所需的JSON格式的数据
/// </summary>
/// <param name="context">报表输出上下文</param>
/// <returns></returns>
Task<dynamic?> GetDataAsync(ReportContext context);
}
}

@ -927,110 +927,33 @@ namespace DS.WMS.Core.Fee.Method
} }
/// <summary> /// <summary>
/// 获取费用核算单打印信息 /// 获取费用打印信息
/// </summary> /// </summary>
/// <param name="providerName"></param>
/// <param name="businessType">业务类型</param> /// <param name="businessType">业务类型</param>
/// <param name="idArray">费用记录ID</param> /// <param name="idArray">费用记录ID</param>
/// <returns></returns> /// <returns></returns>
public async Task<DataResult<CostAccountingForm>> GetPrintInfoAsync(BusinessType businessType, params long[] idArray) public async Task<DataResult<dynamic>> GetPrintInfoAsync(string providerName, BusinessType businessType, params long[] idArray)
{ {
CostAccountingForm form = null; Type type = Type.GetType(providerName, false);
switch (businessType) if (type == null)
{ return DataResult<dynamic>.Failed("未能找到数据提供程序");
case BusinessType.OceanShippingExport:
form = await GetOceanShippingExportAsync(idArray);
break;
case BusinessType.OceanShippingImport:
break;
default:
return DataResult<CostAccountingForm>.Failed(string.Format(
MultiLanguageConst.BusinessNotSupported, businessType.GetDescription()));
}
if (form != null) var provider = Fasterflect.ConstructorExtensions.CreateInstance(type) as IReportProvider;
var context = new ReportContext
{ {
long UserId = long.Parse(User.UserId); BusinessType = businessType,
form.Creator = Db.Queryable<SysUser>().Where(x => x.Id == UserId).Select(x => x.UserName).First(); Ids = idArray,
Db = Db,
form.ReceivableRMB = form.Details.FindAll(x => x.Type == FeeType.Receivable && x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.Amount); TenantDb = TenantDb,
form.PayableRMB = form.Details.FindAll(x => x.Type == FeeType.Payable && x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.Amount); User = User,
form.ReceivableUSD = form.Details.FindAll(x => x.Type == FeeType.Receivable && x.Currency == FeeCurrency.USD_CODE).Sum(x => x.Amount); ServiceProvider = ServiceProvider
form.PayableUSD = form.Details.FindAll(x => x.Type == FeeType.Payable && x.Currency == FeeCurrency.USD_CODE).Sum(x => x.Amount);
form.ReceivableOther = form.Details.FindAll(x => x.Type == FeeType.Receivable && (x.Currency != FeeCurrency.RMB_CODE && x.Currency != FeeCurrency.USD_CODE)).Sum(x => x.Amount);
form.PayableOther = form.Details.FindAll(x => x.Type == FeeType.Payable && (x.Currency == FeeCurrency.RMB_CODE && x.Currency != FeeCurrency.USD_CODE)).Sum(x => x.Amount);
//获取美元汇率
var fees = new List<FeeRecord> {
new FeeRecord { Currency = FeeCurrency.USD_CODE, FeeType = FeeType.Receivable },
new FeeRecord { Currency = FeeCurrency.USD_CODE, FeeType = FeeType.Payable }
};
await FetchExchangeRateAsync(fees);
form.ExchangeRate = fees[0].ExchangeRate.HasValue ? fees[0].ExchangeRate.Value : 1;
form.TotalReceivable = Math.Round(form.ReceivableUSD * form.ExchangeRate, 4, MidpointRounding.ToEven) + form.ReceivableRMB + form.ReceivableOther;
form.TotalPayable = Math.Round(form.PayableUSD * form.ExchangeRate, 4, MidpointRounding.ToEven) + form.PayableRMB + form.PayableOther;
}
return DataResult<CostAccountingForm>.Success(form);
}
//获取海运出口打印数据
async Task<CostAccountingForm> GetOceanShippingExportAsync(params long[] idArray)
{
CostAccountingForm form = null;
var list = await TenantDb.Queryable<FeeRecord>().InnerJoin<SeaExport>((x, y) => x.BusinessId == y.Id)
.Where((x, y) => idArray.Contains(x.Id)
//&& x.FeeStatus == FeeStatus.SettlementCompleted
).Select((x, y) => new
{
x.FeeType,
x.FeeName,
x.Currency,
x.ExchangeRate,
x.Amount,
x.CustomerName,
y.CustomerNo, //业务编号
y.AccountDate, //会计期间
y.ETA,
y.ETD,
y.Voyno,
y.MBLNO,
y.Carrier,
y.LoadPort,
y.DischargePort,
y.CntrTotal, //Volume
y.IssueType //放单方式
}).ToListAsync();
if (list.Count == 0)
return form;
var item = list[0];
form = new CostAccountingForm
{
BusinessNo = item.CustomerNo,
AccountingPeriod = item.AccountDate,
ETA = item.ETA,
ETD = item.ETD,
Voy = item.Voyno,
MBLNo = item.MBLNO,
Carrier = item.Carrier,
POL = item.LoadPort,
POD = item.DischargePort,
Volume = item.CntrTotal,
ReleaseType = item.IssueType,
PrintTime = DateTime.Now,
Details = list.Select(x => new CostAccountingDetail
{
Amount = x.Amount,
Currency = x.Currency,
CustomerName = x.CustomerName,
FeeName = x.FeeName,
Type = x.FeeType
}).ToList()
}; };
var data = provider.GetDataAsync(context);
if (context.ErrorResult == null)
return DataResult<dynamic>.Success(data);
return form; return DataResult<dynamic>.Failed(context.ErrorResult.Message, context.ErrorResult.MultiCode);
} }
/// <summary> /// <summary>

@ -0,0 +1,123 @@
using DS.Module.Core;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Entity;
using Masuit.Tools.Systems;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace DS.WMS.Core.Fee.Method.ReportProviders
{
/// <summary>
/// 费用核算单
/// </summary>
public class CostAccountingReport : IReportProvider
{
public async Task<dynamic?> GetDataAsync(ReportContext context)
{
CostAccountingForm? form = null;
switch (context.BusinessType)
{
case BusinessType.OceanShippingExport:
form = await GetOceanShippingExportAsync(context.TenantDb, context.Ids);
break;
case BusinessType.OceanShippingImport:
break;
default:
context.ErrorResult = DataResult.Failed(string.Format(MultiLanguageConst.GetDescription(
MultiLanguageConst.BusinessNotSupported), context.BusinessType.GetDescription()));
break;
}
if (form != null)
{
long UserId = long.Parse(context.User.UserId);
form.Creator = context.Db.Queryable<SysUser>().Where(x => x.Id == UserId).Select(x => x.UserName).First();
form.ReceivableRMB = form.Details.FindAll(x => x.Type == FeeType.Receivable && x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.Amount);
form.PayableRMB = form.Details.FindAll(x => x.Type == FeeType.Payable && x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.Amount);
form.ReceivableUSD = form.Details.FindAll(x => x.Type == FeeType.Receivable && x.Currency == FeeCurrency.USD_CODE).Sum(x => x.Amount);
form.PayableUSD = form.Details.FindAll(x => x.Type == FeeType.Payable && x.Currency == FeeCurrency.USD_CODE).Sum(x => x.Amount);
form.ReceivableOther = form.Details.FindAll(x => x.Type == FeeType.Receivable && (x.Currency != FeeCurrency.RMB_CODE && x.Currency != FeeCurrency.USD_CODE)).Sum(x => x.Amount);
form.PayableOther = form.Details.FindAll(x => x.Type == FeeType.Payable && (x.Currency == FeeCurrency.RMB_CODE && x.Currency != FeeCurrency.USD_CODE)).Sum(x => x.Amount);
//获取美元汇率
var currencyService = context.ServiceProvider.GetRequiredService<IFeeCurrencyExchangeService>();
var exchange = new ExchangeRate
{
CurrencyFrom = FeeCurrency.USD_CODE,
CurrencyTo = FeeCurrency.RMB_CODE
};
exchange = (await currencyService.GetExchangeRateAsync(exchange))?.Data;
form.ExchangeRate = exchange.Rate;
form.TotalReceivable = Math.Round(form.ReceivableUSD * form.ExchangeRate, 4, MidpointRounding.ToEven) + form.ReceivableRMB + form.ReceivableOther;
form.TotalPayable = Math.Round(form.PayableUSD * form.ExchangeRate, 4, MidpointRounding.ToEven) + form.PayableRMB + form.PayableOther;
}
return form;
}
//获取海运出口打印数据
static async Task<CostAccountingForm> GetOceanShippingExportAsync(ISqlSugarClient tenantDb, params long[] idArray)
{
CostAccountingForm form = null;
var list = await tenantDb.Queryable<FeeRecord>().InnerJoin<SeaExport>((x, y) => x.BusinessId == y.Id)
.Where((x, y) => idArray.Contains(x.Id)
//&& x.FeeStatus == FeeStatus.SettlementCompleted
).Select((x, y) => new
{
x.FeeType,
x.FeeName,
x.Currency,
x.ExchangeRate,
x.Amount,
x.CustomerName,
y.CustomerNo, //业务编号
y.AccountDate, //会计期间
y.ETA,
y.ETD,
y.Voyno,
y.MBLNO,
y.Carrier,
y.LoadPort,
y.DischargePort,
y.CntrTotal, //Volume
y.IssueType //放单方式
}).ToListAsync();
if (list.Count == 0)
return form;
var item = list[0];
form = new CostAccountingForm
{
BusinessNo = item.CustomerNo,
AccountingPeriod = item.AccountDate,
ETA = item.ETA,
ETD = item.ETD,
Voy = item.Voyno,
MBLNo = item.MBLNO,
Carrier = item.Carrier,
POL = item.LoadPort,
POD = item.DischargePort,
Volume = item.CntrTotal,
ReleaseType = item.IssueType,
PrintTime = DateTime.Now,
Details = list.Select(x => new CostAccountingDetail
{
Amount = x.Amount,
Currency = x.Currency,
CustomerName = x.CustomerName,
FeeName = x.FeeName,
Type = x.FeeType
}).ToList()
};
return form;
}
}
}

@ -463,7 +463,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
{ {
BusinessTask task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).FirstAsync(); BusinessTask task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).FirstAsync();
if (task == null) if (task == null)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData)); return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskNotExists));
if (task.TaskStatus == TaskStatusEnum.Complete) if (task.TaskStatus == TaskStatusEnum.Complete)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCompleted)); return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCompleted));
//if (task.TaskStatus == TaskStatusEnum.Cancel) //if (task.TaskStatus == TaskStatusEnum.Cancel)
@ -869,16 +869,20 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
if (callback.FlowStatus == FlowStatusEnum.Reject) if (callback.FlowStatus == FlowStatusEnum.Reject)
{ {
var task = await GetQuery(callback.BusinessId, callback.BusinessType, callback.AuditType.Value).FirstAsync(); var task = await GetQuery(callback.BusinessId, callback.BusinessType, callback.AuditType.Value).FirstAsync();
//创建驳回任务以进行通知 var request = new TaskCreationRequest
await CreateTaskAsync(new TaskCreationRequest
{ {
BusinessId = callback.BusinessId, BusinessId = callback.BusinessId,
BusinessType = callback.BusinessType, BusinessType = callback.BusinessType,
TaskTypeName = GetRejectedType(callback.AuditType.Value).ToString(), TaskTypeName = GetRejectedType(callback.AuditType.Value).ToString(),
RecvUserIdList = [task.CreateBy] //通知任务发起人 RecvUserIdList = [task.CreateBy] //通知任务发起人
}); };
//创建驳回任务以进行通知
await CreateTaskAsync(request);
//更新任务描述为驳回原因
await SetTaskBaseDescription(callback.BusinessId, request.TaskType, callback.RejectReason);
remark += ";驳回理由:" + callback.RejectReason; remark += ";驳回原因" + callback.RejectReason;
} }
long userId = long.Parse(User.UserId); long userId = long.Parse(User.UserId);

@ -3,6 +3,7 @@ using DS.Module.Core.Data;
using DS.WMS.Core.Fee.Dtos; using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Entity; using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface; using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Fee.Method.ReportProviders;
using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Entity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -204,12 +205,16 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="model">费用记录ID</param> /// <param name="model">费用记录ID</param>
/// <returns></returns> /// <returns></returns>
[HttpPost, Route("GetPrintInfo")] [HttpPost, Route("GetPrintInfo")]
public async Task<DataResult<CostAccountingForm>> GetPrintInfoAsync(IdModel model) public async Task<DataResult<dynamic>> GetPrintInfoAsync(IdModel model)
{ {
if (model == null || model.Ids?.Length == 0) if (model == null || model.Ids?.Length == 0)
return DataResult<CostAccountingForm>.Failed("参数无效", MultiLanguageConst.IllegalRequest); return DataResult<dynamic>.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await _feeService.GetPrintInfoAsync((BusinessType)model.BusinessType.Value, model.Ids); string providerName = model.Value?.ToString();
if (string.IsNullOrEmpty(providerName))
providerName = typeof(CostAccountingReport).AssemblyQualifiedName;
return await _feeService.GetPrintInfoAsync(providerName, (BusinessType)model.BusinessType.Value, model.Ids);
} }
/// <summary> /// <summary>

@ -87,4 +87,17 @@ public class CodeDataRuleTemplateController : ApiController
var res =await _invokeService.BatchDelDataRuleTemplate(req); var res =await _invokeService.BatchDelDataRuleTemplate(req);
return res; return res;
} }
/// <summary>
/// 批量复制
/// </summary>
/// <param name="req">Ids</param>
/// <returns></returns>
[HttpPost]
[Route("BatchCopyDataRuleTemplate")]
public async Task<DataResult> BatchCopyDataRuleTemplate([FromBody] IdModel req)
{
var res = await _invokeService.BatchCopyDataRuleTemplate(req);
return res;
}
} }
Loading…
Cancel
Save