退舱改配问题修复

dev
cjy 4 weeks ago
parent 58eebe9388
commit 6d5cb3ee7b

@ -24,7 +24,15 @@ namespace DS.Module.ExcelModule
{ {
private readonly IServiceProvider _serviceProvider; private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db; private readonly ISqlSugarClient db;
static readonly ApiFox api;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="serviceProvider"></param>
static ExcelService()
{
api = new ApiFox();
}
/// <summary> /// <summary>
/// 构造函数 /// 构造函数
/// </summary> /// </summary>
@ -33,7 +41,6 @@ namespace DS.Module.ExcelModule
{ {
_serviceProvider = serviceProvider; _serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>(); db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
} }
public DataResult<string> ExportExcelByColumn(ExportByColumnReq req) public DataResult<string> ExportExcelByColumn(ExportByColumnReq req)
{ {
@ -51,7 +58,7 @@ namespace DS.Module.ExcelModule
for (int n = 0; n < req.ColumnSets.Count; n++) for (int n = 0; n < req.ColumnSets.Count; n++)
{ {
var columnSet = req.ColumnSets[n]; var columnSet = req.ColumnSets[n];
var key = columnSet.DataIndex; var key = columnSet.DataIndex;
info.Add(columnSet.Title, temp[key]); info.Add(columnSet.Title, temp[key]);
} }
values.Add(info); values.Add(info);
@ -60,6 +67,29 @@ namespace DS.Module.ExcelModule
return DataResult<string>.Success(path); return DataResult<string>.Success(path);
} }
public async Task<MemoryStream> ExportExcelStreamByColumnAsync(ExportByColumnReq req)
{
var data = JArray.Parse(req.JsonDataStr);
var values = new List<Dictionary<string, object>>();
for (int i = 0; i < data.Count; i++)
{
var temp = data[i];
var info = new Dictionary<string, object>();
for (int n = 0; n < req.ColumnSets.Count; n++)
{
var columnSet = req.ColumnSets[n];
var key = columnSet.DataIndex;
info.Add(columnSet.Title, temp[key]);
}
values.Add(info);
}
var stream = new MemoryStream();
await MiniExcel.SaveAsAsync(stream, values);
stream.Seek(0, SeekOrigin.Begin);
return stream;
}
public MemoryStream ExportExcelStreamByColumn(ExportByColumnReq req) public MemoryStream ExportExcelStreamByColumn(ExportByColumnReq req)
{ {

@ -26,5 +26,11 @@ namespace DS.Module.ExcelModule
/// <returns></returns> /// <returns></returns>
public MemoryStream ExportExcelStreamByColumn(ExportByColumnReq req); public MemoryStream ExportExcelStreamByColumn(ExportByColumnReq req);
/// <summary>
///
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public Task<MemoryStream> ExportExcelStreamByColumnAsync(ExportByColumnReq req);
} }
} }

@ -0,0 +1,30 @@
using DS.Module.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.Module.ExcelModule.Model
{
/// <summary>
/// 导出Excel通用请求
/// </summary>
public class ExportExcelReq
{
/// <summary>
/// 请求路由Url
/// </summary>
public string Url { get; set; }
/// <summary>
/// 查询条件
/// </summary>
public PageRequest QueryRequest { get; set; }
/// <summary>
/// 用户自定义列设置
/// </summary>
public List<UserColumnSet> ColumnSets { get; set; }
}
}

@ -324,7 +324,7 @@ public class SeaExportBillManage : BaseOrgModel<long>
/// <summary> /// <summary>
/// 签单方式 t_code_issutype /// 签单方式 t_code_issutype
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "签单方式", IsNullable = true, Length = 12)] [SugarColumn(ColumnDescription = "签单方式", IsNullable = true, Length = 30)]
public string IssueType { get; set; } public string IssueType { get; set; }
/// <summary> /// <summary>

@ -299,14 +299,14 @@ namespace DS.WMS.Core.Op.Method
await tenantDb.Insertable(list).ExecuteCommandAsync(); await tenantDb.Insertable(list).ExecuteCommandAsync();
} }
//更新主表货运跟踪 //更新主表货运跟踪
var statusLogs = await tenantDb.Queryable<BookingStatusLog>().Where(x => x.BusinessId == req.Id).ToListAsync(); var bookingGoods = await tenantDb.Queryable<BookingGoodsStatus>().Where(x => x.BusinessId == req.Id).ToListAsync();
if (statusLogs.IsNotNull() && statusLogs.Count > 0) if (bookingGoods.IsNotNull() && bookingGoods.Count > 0)
{ {
foreach (var item in statusLogs) foreach (var item in bookingGoods)
{ {
item.BusinessId = newKey; item.BusinessId = newKey;
} }
await tenantDb.Updateable(statusLogs).ExecuteCommandAsync(); await tenantDb.Updateable(bookingGoods).ExecuteCommandAsync();
} }
//任务交互表 //任务交互表
var taskList = await tenantDb.Queryable<BusinessTask>().Where(x => x.BusinessId == req.Id).ToListAsync(); var taskList = await tenantDb.Queryable<BusinessTask>().Where(x => x.BusinessId == req.Id).ToListAsync();

@ -22,6 +22,11 @@ using Microsoft.AspNetCore.Authorization;
using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing;
using System.IO; using System.IO;
using System.Web; using System.Web;
using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Flow.Entity;
using DS.WMS.Core;
using MathNet.Numerics;
using NPOI.SS.Formula.Functions;
namespace DS.WMS.MainApi.Controllers namespace DS.WMS.MainApi.Controllers
{ {
@ -53,6 +58,50 @@ namespace DS.WMS.MainApi.Controllers
return _invokeService.ExportExcelByColumn(req); return _invokeService.ExportExcelByColumn(req);
} }
//[HttpPost]
//[Route("CommonExcelExportAsync")]
//public async Task<IActionResult> CommonExcelExportAsync([FromBody] ExportExcelReq req)
//{
// if (instance.CallbackURL.IsNullOrEmpty())
// return;
// //请求参数设置
// var callback = new FlowCallback
// {
// InstanceId = instance.Id,
// BusinessId = instance.BusinessId,
// BusinessType = instance.BusinessType,
// AuditType = instance.AuditType,
// FlowStatus = instance.FlowStatus,
// RejectReason = instance.Note
// };
// if (api.DefaultHeaders.Contains("Authorization"))
// api.DefaultHeaders.Remove("Authorization");
// api.DefaultHeaders.Add("Authorization", "Bearer " + User.GetToken());
// try
// {
// var result = await api.PostAsync<DataResult>(instance.CallbackURL, callback);
// if (result.Succeeded)
// {
// //更新回调执行标识
// await Db.Updateable<FlowInstance>().SetColumns(it => it.IsCallbackExecuted == true)
// .Where(it => it.Id == instance.Id).ExecuteCommandAsync();
// }
// else
// {
// await new ApplicationException($"访问回调URL{instance.CallbackURL} 时返回了错误:" + result.Message).LogAsync(Db);
// }
// }
// catch (Exception ex)
// {
// await ex.LogAsync(Db);
// }
//}
/// <summary> /// <summary>
/// 根据用户列导出Excel文件流 /// 根据用户列导出Excel文件流
/// </summary> /// </summary>

Loading…
Cancel
Save