dev
dengyu 1 month ago
parent c57eaef663
commit 16ec13a6b8

@ -257,6 +257,32 @@ namespace DS.Module.Core.Enums
/// </summary>
[Description("已还箱")]
= 101,
/// <summary>
/// 进口
/// </summary>
[Description("进口")]
= 102,
/// <summary>
/// 出口
/// </summary>
[Description("出口")]
= 103,
/// <summary>
/// 拆空
/// </summary>
[Description("拆空")]
= 104,
/// <summary>
/// 调入
/// </summary>
[Description("调入")]
= 105,
/// <summary>
/// 空出
/// </summary>
[Description("空出")]
= 106,
}
/// <summary>

@ -13,6 +13,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OfficeOpenXml;
using NPOI.Util;
using NPOI.SS.UserModel;
using NPOI.HPSF;
namespace DS.Module.ExcelModule
{
@ -59,9 +63,10 @@ namespace DS.Module.ExcelModule
public MemoryStream ExportExcelStreamByColumn(ExportByColumnReq req)
{
var filename = Guid.NewGuid() + ".xlsx";
//var filename = Guid.NewGuid() + ".xlsx";
//var path = Path.Combine(_environment.WebRootPath, "export/" + filename);
var path = Path.Combine("", "wwwroot/export/" + filename);
//var path = Path.Combine("", "wwwroot/export/" + filename);
var data = JArray.Parse(req.JsonDataStr);
var values = new List<Dictionary<string, object>>();
@ -78,10 +83,63 @@ namespace DS.Module.ExcelModule
}
values.Add(info);
}
var memoryStream = new MemoryStream();
memoryStream.SaveAs(values);
memoryStream.Seek(0, SeekOrigin.Begin);
return memoryStream;
var stream = new MemoryStream();
MiniExcel.SaveAs(stream, values);
stream.Seek(0, SeekOrigin.Begin);
return stream;
//var data = JArray.Parse(req.JsonDataStr);
//ExcelPackage.LicenseContext = LicenseContext.NonCommercial; // 设置许可
//var stream = new MemoryStream();
//using (var package = new ExcelPackage(stream))
//{
// var worksheet = package.Workbook.Worksheets.Add("Sheet1");
// // 填充数据
// //worksheet.Cells[1, 1].Value = "Column1";
// //worksheet.Cells[1, 2].Value = "Column2";
// //worksheet.Cells[2, 1].Value = "Data1";
// //worksheet.Cells[2, 2].Value = "Data2";
// if (data != null && req.ColumnSets != null)
// {
// var _count = 1;
// foreach (var title in req.ColumnSets) {
// worksheet.Cells[1, _count].Value = title.Title;
// _count++;
// }
// for (int i = 0; i < data.Count; i++)
// {
// var temp = data[i];
// for (int n = 0; n < req.ColumnSets.Count; n++)
// {
// var columnSet = req.ColumnSets[n];
// var key = columnSet.DataIndex;
// worksheet.Cells[i+2, n+1].Value = temp[key].ToString();
// }
// }
// }
// // 保存
// package.Save();
//}
////using (var fileStream = File.Create("D:\\temp.xlsx"))
////{
//// stream.Seek(0, SeekOrigin.Begin);//设置复制开始的地方
//// stream.CopyTo(fileStream);
////}
//stream.Seek(0, SeekOrigin.Begin);
//stream.Position = 0;
//return stream;
}
}
}

@ -1,6 +1,7 @@
using DS.Module.Core;
using DS.Module.ExcelModule.Model;
using Microsoft.AspNetCore.Mvc;
using Org.BouncyCastle.Crypto.Paddings;
using System;
using System.Collections.Generic;
using System.Linq;
@ -24,5 +25,6 @@ namespace DS.Module.ExcelModule
/// <param name="req"></param>
/// <returns></returns>
public MemoryStream ExportExcelStreamByColumn(ExportByColumnReq req);
}
}

@ -12,6 +12,8 @@ namespace DS.Module.ExcelModule.Model
/// </summary>
public class ExportByColumnReq
{
public string Title { get; set; }
/// <summary>
/// 用户自定义列设置
/// </summary>

@ -49,8 +49,9 @@ public class MultiLanguageMiddleware
|| context.Request.Path.Value.IndexOf("LinkAttach", StringComparison.InvariantCultureIgnoreCase) > -1
|| context.Request.Path.Value.IndexOf("PrintTempFile", StringComparison.InvariantCultureIgnoreCase) > -1
|| context.Request.Path.Value.IndexOf("GetOcrImg", StringComparison.InvariantCultureIgnoreCase) > -1
|| context.Request.Path.Value.IndexOf("DownloadBookingOrClosingEDI", StringComparison.InvariantCultureIgnoreCase) > -1
|| context.Request.Path.Value.IndexOf("DownloadFile", StringComparison.InvariantCultureIgnoreCase) > -1
|| 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
)
)
{

@ -200,6 +200,51 @@ public class CM_CurrentStateReq
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 始发港
/// </summary>
public string PortLoad { get; set; }
/// <summary>
/// Desc:始发港代码
/// </summary>
public long? PortLoadid { get; set; }
/// <summary>
/// Desc:始发港五字码
/// </summary>
public string PortLoadCode { get; set; }
/// <summary>
/// 目的港
/// </summary>
public string PortDelivery { get; set; }
/// <summary>
/// Desc:目的港代码
/// </summary>
public long? PortDeliveryid { get; set; }
/// <summary>
/// Desc:目的港五字码
/// </summary>
public string PortDeliveryCode { get; set; }
/// <summary>
/// 预抵港
/// </summary>
public string PortDischarge { get; set; }
/// <summary>
/// Desc:预抵港代码
/// </summary>
public long? PortDischargeid { get; set; }
/// <summary>
/// Desc:预抵港五字码
/// </summary>
public string PortDischargeCode { get; set; }
}
/// <summary>

@ -194,4 +194,46 @@ public class CM_CurrentStateRes: BaseFieldRes
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// Desc:始发港代码
/// </summary>
public long? PortLoadid { get; set; }
/// <summary>
/// Desc:始发港五字码
/// </summary>
public string PortLoadCode { get; set; }
/// <summary>
/// 目的港
/// </summary>
public string PortDelivery { get; set; }
/// <summary>
/// Desc:目的港代码
/// </summary>
public long? PortDeliveryid { get; set; }
/// <summary>
/// Desc:目的港五字码
/// </summary>
public string PortDeliveryCode { get; set; }
/// <summary>
/// 预抵港
/// </summary>
public string PortDischarge { get; set; }
/// <summary>
/// Desc:预抵港代码
/// </summary>
public long? PortDischargeid { get; set; }
/// <summary>
/// Desc:预抵港五字码
/// </summary>
public string PortDischargeCode { get; set; }
}

@ -213,6 +213,53 @@ public class CM_State_ChangeReq
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 始发港
/// </summary>
public string PortLoad { get; set; }
/// <summary>
/// Desc:始发港代码
/// </summary>
public long? PortLoadid { get; set; }
/// <summary>
/// Desc:始发港五字码
/// </summary>
public string PortLoadCode { get; set; }
/// <summary>
/// 目的港
/// </summary>
public string PortDelivery { get; set; }
/// <summary>
/// Desc:目的港代码
/// </summary>
public long? PortDeliveryid { get; set; }
/// <summary>
/// Desc:目的港五字码
/// </summary>
public string PortDeliveryCode { get; set; }
/// <summary>
/// 预抵港
/// </summary>
public string PortDischarge { get; set; }
/// <summary>
/// Desc:预抵港代码
/// </summary>
public long? PortDischargeid { get; set; }
/// <summary>
/// Desc:预抵港五字码
/// </summary>
public string PortDischargeCode { get; set; }
/// <summary>
/// 用于判断是否是相同的变动
/// 依据是:

@ -189,4 +189,50 @@ public class CM_State_ChangeRes : BaseFieldRes
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 始发港
/// </summary>
public string PortLoad { get; set; }
/// <summary>
/// Desc:始发港代码
/// </summary>
public long? PortLoadid { get; set; }
/// <summary>
/// Desc:始发港五字码
/// </summary>
public string PortLoadCode { get; set; }
/// <summary>
/// 目的港
/// </summary>
public string PortDelivery { get; set; }
/// <summary>
/// Desc:目的港代码
/// </summary>
public long? PortDeliveryid { get; set; }
/// <summary>
/// Desc:目的港五字码
/// </summary>
public string PortDeliveryCode { get; set; }
/// <summary>
/// 预抵港
/// </summary>
public string PortDischarge { get; set; }
/// <summary>
/// Desc:预抵港代码
/// </summary>
public long? PortDischargeid { get; set; }
/// <summary>
/// Desc:预抵港五字码
/// </summary>
public string PortDischargeCode { get; set; }
}

@ -218,6 +218,51 @@ public class CM_State_Change_TempReq
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 始发港
/// </summary>
public string PortLoad { get; set; }
/// <summary>
/// Desc:始发港代码
/// </summary>
public long? PortLoadid { get; set; }
/// <summary>
/// Desc:始发港五字码
/// </summary>
public string PortLoadCode { get; set; }
/// <summary>
/// 目的港
/// </summary>
public string PortDelivery { get; set; }
/// <summary>
/// Desc:目的港代码
/// </summary>
public long? PortDeliveryid { get; set; }
/// <summary>
/// Desc:目的港五字码
/// </summary>
public string PortDeliveryCode { get; set; }
/// <summary>
/// 预抵港
/// </summary>
public string PortDischarge { get; set; }
/// <summary>
/// Desc:预抵港代码
/// </summary>
public long? PortDischargeid { get; set; }
/// <summary>
/// Desc:预抵港五字码
/// </summary>
public string PortDischargeCode { get; set; }
/// <summary>
/// 用于判断是否是相同的变动
/// 依据是:

@ -194,4 +194,51 @@ public class CM_State_Change_TempRes : BaseFieldRes
/// 备注
/// </summary>
public string Remark { get; set; }
public string DealRemark { get; set; }
/// <summary>
/// 始发港
/// </summary>
public string PortLoad { get; set; }
/// <summary>
/// Desc:始发港代码
/// </summary>
public long? PortLoadid { get; set; }
/// <summary>
/// Desc:始发港五字码
/// </summary>
public string PortLoadCode { get; set; }
/// <summary>
/// 目的港
/// </summary>
public string PortDelivery { get; set; }
/// <summary>
/// Desc:目的港代码
/// </summary>
public long? PortDeliveryid { get; set; }
/// <summary>
/// Desc:目的港五字码
/// </summary>
public string PortDeliveryCode { get; set; }
/// <summary>
/// 预抵港
/// </summary>
public string PortDischarge { get; set; }
/// <summary>
/// Desc:预抵港代码
/// </summary>
public long? PortDischargeid { get; set; }
/// <summary>
/// Desc:预抵港五字码
/// </summary>
public string PortDischargeCode { get; set; }
}

@ -147,7 +147,7 @@ public class CM_CurrentState : BaseOrgModel<long>
/// <summary>
/// Desc:当前港口
/// </summary>
[SugarColumn(ColumnDescription = "当前港口", IsNullable = true, Length = 50)]
[SugarColumn(ColumnDescription = "当前港口", IsNullable = true, Length = 60)]
public string Port { get; set; }
/// <summary>
@ -205,5 +205,60 @@ public class CM_CurrentState : BaseOrgModel<long>
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "备注", IsNullable = true, Length = 400)]
public string Remark { get; set; }
/// <summary>
/// 始发港
/// </summary>
[SugarColumn(ColumnDescription = "始发港", IsNullable = true, Length = 60)]
public string PortLoad { get; set; }
/// <summary>
/// Desc:始发港代码
/// </summary>
[SugarColumn(ColumnDescription = "始发港代码", IsNullable = true)]
public long? PortLoadid { get; set; }
/// <summary>
/// Desc:始发港五字码
/// </summary>
[SugarColumn(ColumnDescription = "始发港五字码", IsNullable = true, Length = 10)]
public string PortLoadCode { get; set; }
/// <summary>
/// 目的港
/// </summary>
[SugarColumn(ColumnDescription = "目的港", IsNullable = true, Length = 60)]
public string PortDelivery { get; set; }
/// <summary>
/// Desc:目的港代码
/// </summary>
[SugarColumn(ColumnDescription = "目的港代码", IsNullable = true)]
public long? PortDeliveryid { get; set; }
/// <summary>
/// Desc:目的港五字码
/// </summary>
[SugarColumn(ColumnDescription = "目的港五字码", IsNullable = true, Length = 10)]
public string PortDeliveryCode { get; set; }
/// <summary>
/// 预抵港
/// </summary>
[SugarColumn(ColumnDescription = "预抵港", IsNullable = true, Length = 60)]
public string PortDischarge { get; set; }
/// <summary>
/// Desc:预抵港代码
/// </summary>
[SugarColumn(ColumnDescription = "预抵港代码", IsNullable = true)]
public long? PortDischargeid { get; set; }
/// <summary>
/// Desc:预抵港五字码
/// </summary>
[SugarColumn(ColumnDescription = "预抵港五字码", IsNullable = true, Length = 10)]
public string PortDischargeCode { get; set; }
}

@ -212,5 +212,59 @@ public class CM_State_Change : BaseOrgModel<long>
[SqlSugar.SugarColumn(ColumnDescription = "备注", IsNullable = true, Length = 400)]
public string Remark { get; set; }
/// <summary>
/// 始发港
/// </summary>
[SugarColumn(ColumnDescription = "始发港", IsNullable = true, Length = 60)]
public string PortLoad { get; set; }
/// <summary>
/// Desc:始发港代码
/// </summary>
[SugarColumn(ColumnDescription = "始发港代码", IsNullable = true)]
public long? PortLoadid { get; set; }
/// <summary>
/// Desc:始发港五字码
/// </summary>
[SugarColumn(ColumnDescription = "始发港五字码", IsNullable = true, Length = 10)]
public string PortLoadCode { get; set; }
/// <summary>
/// 目的港
/// </summary>
[SugarColumn(ColumnDescription = "目的港", IsNullable = true, Length = 60)]
public string PortDelivery { get; set; }
/// <summary>
/// Desc:目的港代码
/// </summary>
[SugarColumn(ColumnDescription = "目的港代码", IsNullable = true)]
public long? PortDeliveryid { get; set; }
/// <summary>
/// Desc:目的港五字码
/// </summary>
[SugarColumn(ColumnDescription = "目的港五字码", IsNullable = true, Length = 10)]
public string PortDeliveryCode { get; set; }
/// <summary>
/// 预抵港
/// </summary>
[SugarColumn(ColumnDescription = "预抵港", IsNullable = true, Length = 60)]
public string PortDischarge { get; set; }
/// <summary>
/// Desc:预抵港代码
/// </summary>
[SugarColumn(ColumnDescription = "预抵港代码", IsNullable = true)]
public long? PortDischargeid { get; set; }
/// <summary>
/// Desc:预抵港五字码
/// </summary>
[SugarColumn(ColumnDescription = "预抵港五字码", IsNullable = true, Length = 10)]
public string PortDischargeCode { get; set; }
}

@ -422,7 +422,7 @@ public class CM_RentOutService : CMServiceBase, ICM_RentOutService
changerec.CtnFlowStateId = CMCtnFlowStateEnum.;
changerec.ChangeTime = detail.PickupDate;
changerec.IsOnlineId = CM_IsOnlineEnum.线;
changerec.IsOnlineId = CM_IsOnlineEnum.线;
}
if (changerec.ChangeTime == null) changerec.ChangeTime = DateTime.Now;

@ -46,6 +46,7 @@ using SharpCompress.Common;
using System.Threading;
using DS.WMS.Core.Code.Entity;
using NPOI.OpenXmlFormats;
using System.Runtime.CompilerServices;
namespace DS.WMS.ContainerManagement.Info.Method;
@ -844,8 +845,13 @@ public class CM_State_Change_TemplatImportService : CMServiceBase, ICM_State_Cha
// db.Queryable<SysDictType>()
var head = await db.Queryable<SysDictType>().FirstAsync(x => x.Code == "CM_StateChange_Field");
var = await db.Queryable<SysDictData>().Where(x => x.TypeId == head.Id).ToListAsync();
var head =await tenantDb.Queryable<CM_State_Change_TemplatImport>().FirstAsync(x => x.Id == req.Id);
var = await tenantDb.Queryable<CM_State_Change_TemplatDetail>().Where(x => x.Pid == head.TempletId).ToListAsync();
var excelinfo = tenantDb.Queryable<OpFile>().FirstAsync(x => x.Id == req.FileId).Result;
//正式地址
@ -923,40 +929,40 @@ public class CM_State_Change_TemplatImportService : CMServiceBase, ICM_State_Cha
Type type = newchange.GetType();
var XXDM = "";
var XXHM = "";
var XXCM = "";
var Vessel = "";
var Voyno = "";
foreach (var in )
foreach (var in )
{
if (string.IsNullOrWhiteSpace(.Value))
if (string.IsNullOrWhiteSpace(.FieldName))
continue;
var field = type.GetProperty(.Value);
var field = type.GetProperty(.FieldTitle);
if (field != null && dt.Columns.Contains(.Name))
if (field != null && dt.Columns.Contains(.ColumnTitle))
{
var _value = row[.Name];
var _value = row[.ColumnTitle];
field.SetValue(newchange, _value);
}
else
if (field == null && .Value == "XXDM")
if (field == null && .FieldTitle == "XXDM")
{
XXDM = row[.Name].ToString();
XXDM = row[.ColumnTitle].ToString();
}
else
if (field == null && .Value == "XXHM")
if (field == null && .FieldTitle == "XXCM")
{
XXHM = row[.Name].ToString();
XXCM = row[.ColumnTitle].ToString();
}
else
if (field == null && .Value == "Vessel")
if (field == null && .FieldTitle == "Vessel")
{
Vessel = row[.Name].ToString();
Vessel = row[.ColumnTitle].ToString();
}
else
if (field == null && .Value == "Voyno")
if (field == null && .FieldTitle == "Voyno")
{
Voyno = row[.Name].ToString();
Voyno = row[.ColumnTitle].ToString();
}
else
{
@ -967,8 +973,8 @@ public class CM_State_Change_TemplatImportService : CMServiceBase, ICM_State_Cha
}
}
if (XXDM != "" && XXHM != "") {
newchange.Ctnall= XXDM + XXHM;
if (XXDM != "" && XXCM != "") {
newchange.Ctnall= XXCM+ XXDM ;
}
if (Vessel != "" && Voyno != "")
@ -980,6 +986,73 @@ public class CM_State_Change_TemplatImportService : CMServiceBase, ICM_State_Cha
}
//对于港口类字段 做如下操作:
if (changelist != null && changelist.Count > 0)
{
var portlist = await tenantDb.Queryable<CodePort>().ToListAsync();
portinfo getport(string port) {
var result = new portinfo();
if (portlist.Exists(x => x.PortName == port || x.EdiCode == port)) {
var _r = portlist.First(x => x.PortName == port || x.EdiCode == port);
result.Portid = _r.Id;
result.PortName = _r.PortName;
result.PortCode = _r.EdiCode;
}
return result;
}
foreach (var item in changelist) {
if (!string.IsNullOrWhiteSpace(item.Port))
{
var _port = getport(item.Port);
if (string.IsNullOrWhiteSpace(_port.PortName))
{
item.Port = _port.PortName;
item.Portid = _port.Portid;
item.PortCode = _port.PortCode;
}
}
if (!string.IsNullOrWhiteSpace(item.PortLoad))
{
var _port = getport(item.PortLoad);
if (string.IsNullOrWhiteSpace(_port.PortName))
{
item.PortLoad = _port.PortName;
item.PortLoadid = _port.Portid;
item.PortLoadCode = _port.PortCode;
}
}
if (!string.IsNullOrWhiteSpace(item.PortDelivery))
{
var _port = getport(item.PortDelivery);
if (string.IsNullOrWhiteSpace(_port.PortName))
{
item.PortDelivery = _port.PortName;
item.PortDeliveryid = _port.Portid;
item.PortDeliveryCode = _port.PortCode;
}
}
if (!string.IsNullOrWhiteSpace(item.PortDischarge))
{
var _port = getport(item.PortDischarge);
if (string.IsNullOrWhiteSpace(_port.PortName))
{
item.PortDischarge = _port.PortName;
item.PortDischargeid = _port.Portid;
item.PortDischargeCode = _port.PortCode;
}
}
}
}
if (changelist != null && changelist.Count > 0)
{
await tenantDb.Deleteable<CM_State_Change_Temp>(x => x.Pid == req.Id).ExecuteCommandAsync();
@ -1043,6 +1116,14 @@ public class CM_State_Change_TemplatImportService : CMServiceBase, ICM_State_Cha
return _r;
}
private class portinfo {
public string PortName { get; set; }
public long Portid { get; set; }
public string PortCode { get; set; }
}
private async Task<DataResult> <T,T2>(T ReqItem, T2 InsertItem, CM_DealExcelReq req,bool DoInsert=true) where T : class, new() where T2 : class, new()
{
//Type reqtype = ReqItem.GetType();
@ -1290,7 +1371,7 @@ public class CM_State_Change_TemplatImportService : CMServiceBase, ICM_State_Cha
_pid.SetValue(newchange, req.Id);
var XXDM = "";
var XXHM = "";
var XXCM = "";
var Vessel = "";
var Voyno = "";
@ -1342,9 +1423,9 @@ public class CM_State_Change_TemplatImportService : CMServiceBase, ICM_State_Cha
XXDM = row[.ColumnTitle].ToString();
}
else
if (field == null && .FieldTitle == "XXHM")
if (field == null && .FieldTitle == "XXCM")
{
XXHM = row[.ColumnTitle].ToString();
XXCM = row[.ColumnTitle].ToString();
}
else
if (field == null && .FieldTitle == "Vessel")
@ -1363,11 +1444,11 @@ public class CM_State_Change_TemplatImportService : CMServiceBase, ICM_State_Cha
}
}
if (XXDM != "" && XXHM != "")
if (XXDM != "" && XXCM != "")
{
var field = reqtype.GetProperty("Ctnall");
if(field!=null)
field.SetValue(newchange, XXDM+ XXHM);
field.SetValue(newchange, XXCM+XXDM );
}
if (Vessel != "" && Voyno != "")

@ -2,10 +2,26 @@
using DS.Module.ExcelModule;
using DS.Module.ExcelModule.Model;
using DS.WMS.Core.Code.Interface;
using Masuit.Tools.Files;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using NPOI.HPSF;
using NPOI.XSSF.UserModel;
using SharpCompress.Common;
using System.IO;
using System.Text;
using DS.Module.Core.Data;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Op.Interface;
using DS.WMS.Core.Sys.Dtos;
using DS.WMS.Core.Sys.Interface;
using Microsoft.AspNetCore.Authorization;
using SixLabors.ImageSharp.Drawing;
using System.IO;
using System.Web;
namespace DS.WMS.MainApi.Controllers
{
@ -44,13 +60,68 @@ namespace DS.WMS.MainApi.Controllers
/// <returns></returns>
[HttpPost]
[Route("ExportExcelStreamByColumn")]
public async Task<IActionResult> ExportExcelStreamByColumn([FromBody] ExportByColumnReq req)
[ProducesResponseType(typeof(FileResult), StatusCodes.Status200OK)]
//[AllowAnonymous]
public async Task<IActionResult> ExportExcelStreamByColumn([FromBody] ExportByColumnReq req)//
{
var result = _invokeService.ExportExcelStreamByColumn(req);
HttpContext.Response.Headers.Add("Content-Length", result.Length.ToString());
HttpContext.Response.Headers.Add("Content-Type", "charset=UTF-8");
return File(result, "application/octet-stream;charset=UTF-8", Path.GetFileName(Path.GetRandomFileName() + ".xlsx"));
//return new FileStreamResult(result, "application/octet-stream") { FileDownloadName = Guid.NewGuid().ToString() + ".xlsx" };
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");
var dtstr = DateTime.Now.ToString("yyyyMMddHHmmssfff");
var filename = $"{req.Title}-{dtstr}.xlsx";
byte[] bytes = new byte[result.Length];
result.ReadExactly(bytes, 0, bytes.Length);
string mimeType = "application/octet-stream";
var _r = new FileContentResult(bytes, mimeType)
{
FileDownloadName = filename
};
return _r;
//var path = Path.Combine("", "wwwroot/export/" + filename);
//using (FileStream fileStream = new FileStream(path, FileMode.Create, FileAccess.Write))
//{
// result.WriteTo(fileStream);
//}
//byte[] byteArr = System.IO.File.ReadAllBytes(path);
//string mimeType = "application/octet-stream";
//return new FileContentResult(byteArr, mimeType)
//{
// FileDownloadName = filename
//};
//return File(result, "application/octet-stream;charset=UTF-8",filename);
////return new FileStreamResult(result, "application/octet-stream;charset=UTF-8")
////{
//// FileDownloadName = filename
////};
//return File(result, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", filename);
//var bytes = new byte[result.Length];
//result.Read(bytes, 0, bytes.Length);
//result.Close();
//return new FileContentResult(bytes, "application/octet-stream");
//return new FileStreamResult(result, "application/octet-stream") { FileDownloadName = $"{req.Title}-{dtstr}.xlsx" };
//var provider = new Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider();
//var memi = provider.Mappings[".xlsx"];
//var fileName = Path.GetFileName(filename);
//return File(result, memi, fileName);
//var result = _invokeService.OutputExcel(req);
//return File(result, "application/octet-stream;charset=UTF-8", "UploadTemplate.xlsx");
}
}
}

@ -120,17 +120,17 @@ public class ContainerManagementTest
//tenantDb.CodeFirst.InitTables(types); //指定表空间下的实体
//tenantDb.CodeFirst.InitTables(typeof(OpLetterYard));//指定更新特定实体
//tenantDb.CodeFirst.InitTables(typeof(CM_CurrentState));
tenantDb.CodeFirst.InitTables(typeof(CM_CurrentState));
//tenantDb.CodeFirst.InitTables(typeof(CM_BaseInfo));
//tenantDb.CodeFirst.InitTables(typeof(CM_State_Change));
tenantDb.CodeFirst.InitTables(typeof(CM_State_Change));
//tenantDb.CodeFirst.InitTables(typeof(CM_RentIn));
//tenantDb.CodeFirst.InitTables(typeof(CM_RentIn_Detail));
//tenantDb.CodeFirst.InitTables(typeof(CM_RentOut));
//tenantDb.CodeFirst.InitTables(typeof(CM_RentOut_Detail));
tenantDb.CodeFirst.InitTables(typeof(CM_RentOneWay));
tenantDb.CodeFirst.InitTables(typeof(CM_RentOneWay_Detail));
tenantDb.CodeFirst.InitTables(typeof(CM_RentOneWay_In));
//tenantDb.CodeFirst.InitTables(typeof(CM_RentOneWay));
//tenantDb.CodeFirst.InitTables(typeof(CM_RentOneWay_Detail));
//tenantDb.CodeFirst.InitTables(typeof(CM_RentOneWay_In));
//tenantDb.CodeFirst.InitTables(typeof(CM_BuyCtn));
//tenantDb.CodeFirst.InitTables(typeof(CM_BuyCtn_Detail));
@ -147,7 +147,7 @@ public class ContainerManagementTest
//tenantDb.CodeFirst.InitTables(typeof(CM_State_Change_Templat));
//tenantDb.CodeFirst.InitTables(typeof(CM_State_Change_TemplatDetail));
//tenantDb.CodeFirst.InitTables(typeof(CM_State_Change_TemplatImport));
//tenantDb.CodeFirst.InitTables(typeof(CM_State_Change_Temp));
tenantDb.CodeFirst.InitTables(typeof(CM_State_Change_Temp));
}
Assert.True(true);

Loading…
Cancel
Save