zhangxiaofeng 4 weeks ago
commit 0201a8b247

@ -157,7 +157,15 @@ public static partial class Extensions
return reval;
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static dynamic ObjToDynamic(this object thisValue)
{
return thisValue;
}
/// <summary>
///
/// </summary>

@ -52,6 +52,7 @@ public class MultiLanguageMiddleware
|| context.Request.Path.Value.IndexOf("DownloadBookingOrClosingEDI", StringComparison.InvariantCultureIgnoreCase) > -1
|| context.Request.Path.Value.IndexOf("DownloadFile", StringComparison.InvariantCultureIgnoreCase) > -1
|| context.Request.Path.Value.IndexOf("ExportExcelStreamByColumn", StringComparison.InvariantCultureIgnoreCase) > -1
|| context.Request.Path.Value.IndexOf("CommonExcelExport", StringComparison.InvariantCultureIgnoreCase) > -1
)
)
{

@ -227,7 +227,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
var list = await TenantDb.Queryable<BusinessTask>()
.LeftJoin<SeaExportBillManage>((t, b) => t.BusinessId == b.Id)
.Where((t, b) => t.TaskType == BL_CONFIRM_TASK && t.ParentBusinessId == bsId && t.BusinessType == bsType)
.Where((t, b) => t.ParentBusinessId == bsId && t.BusinessType == bsType)
.Select((t, b) => new BLTask
{
BLNumber = b.HBLNO,

@ -375,7 +375,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
CreateTime = dtNow
}).ToList();
await TenantDb.Insertable(request.Steps).ExecuteCommandAsync();
await TenantDb.Insertable(steps).ExecuteCommandAsync();
}
result = await OnTaskCreated(task);

@ -27,6 +27,12 @@ using DS.WMS.Core.Flow.Entity;
using DS.WMS.Core;
using MathNet.Numerics;
using NPOI.SS.Formula.Functions;
using DS.Module.UserModule;
using SqlSugar;
using Newtonsoft.Json.Linq;
using DS.Module.Core.Extensions;
using LanguageExt.Common;
using DS.WMS.Core.TaskPlat.Dtos;
namespace DS.WMS.MainApi.Controllers
{
@ -35,15 +41,29 @@ namespace DS.WMS.MainApi.Controllers
/// </summary>
public class ExcelController : ApiController
{
private readonly IServiceProvider _serviceProvider;
private readonly IExcelService _invokeService;
private readonly IUser user;
static readonly ApiFox api;
private readonly ISqlSugarClient db;
/// <summary>
/// 构造函数
/// </summary>
static ExcelController()
{
api = new ApiFox();
}
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public ExcelController(IExcelService invokeService)
public ExcelController(IExcelService invokeService, IServiceProvider serviceProvider)
{
_invokeService = invokeService;
_serviceProvider = serviceProvider;
user = _serviceProvider.GetRequiredService<IUser>();
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
}
/// <summary>
@ -58,48 +78,48 @@ namespace DS.WMS.MainApi.Controllers
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>
/// 通用Excel导出
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
[Route("CommonExcelExport")]
[ProducesResponseType(typeof(FileResult), StatusCodes.Status200OK)]
public async Task<IActionResult> CommonExcelExportAsync([FromBody] ExportExcelReq req)
{
if (api.DefaultHeaders.Contains("Authorization"))
api.DefaultHeaders.Remove("Authorization");
api.DefaultHeaders.Add("Authorization", "Bearer " + user.GetToken());
var result = await api.PostAsync<DataResult>(req.Url, req.QueryRequest);
if (!result.Succeeded)
{
await new ApplicationException($"调用URL{req.Url} 时返回了错误:" + result.Message).LogAsync(db);
}
var data = req.Url.Contains("GetSeaExportList") ?JsonConvert.SerializeObject(result.Data.ObjToDynamic()?.Data.list) : JsonConvert.SerializeObject(result.Data.Data);
var res1 = await _invokeService.ExportExcelStreamByColumnAsync(new ExportByColumnReq()
{
JsonDataStr = data,
ColumnSets = req.ColumnSets,
});
var dtstr = DateTime.Now.ToString("yyyyMMddHHmmssfff");
var filename = $"{dtstr}.xlsx";
byte[] bytes = new byte[res1.Length];
res1.ReadExactly(bytes, 0, bytes.Length);
string mimeType = "application/octet-stream";
var _r = new FileContentResult(bytes, mimeType)
{
FileDownloadName = filename
};
return _r;
}
//}
/// <summary>
@ -114,7 +134,7 @@ namespace DS.WMS.MainApi.Controllers
public async Task<IActionResult> ExportExcelStreamByColumn([FromBody] ExportByColumnReq req)//
{
var result = _invokeService.ExportExcelStreamByColumn(req);
var result = _invokeService.ExportExcelStreamByColumn(req);
//HttpContext.Response.Headers.Add("Content-Length", result.Length.ToString());
//HttpContext.Response.Headers.Add("Content-Type", "application/octet-stream;charset=UTF-8");

@ -49,13 +49,13 @@ namespace DS.WMS.OpApi.Controllers
/// <summary>
/// 获取提单确认信息
/// </summary>
/// <param name="bsId">业务ID</param>
/// <param name="bsType">业务类型</param>
/// <param name="businessId">业务ID</param>
/// <param name="businessType">业务类型(可选参数)</param>
/// <returns></returns>
[HttpGet, Route("GetBLConfirmation")]
public async Task<DataResult<BLConfirmation>> GetBLConfirmationAsync(long bsId, BusinessType bsType)
public async Task<DataResult<BLConfirmation>> GetBLConfirmationAsync(long businessId, BusinessType businessType)
{
return await taskService.GetBLConfirmationAsync(bsId, bsType);
return await taskService.GetBLConfirmationAsync(businessId, businessType);
}
/// <summary>

Loading…
Cancel
Save