打印调整为返回文件流

usertest
ZR20090193-陈敬勇 6 months ago
parent d929ad0606
commit 65e7d69fce

@ -21,11 +21,18 @@ namespace DS.Module.PrintModule
/// <returns></returns>
public DataResult GetOpenPrintTemplateList(string id);
///// <summary>
///// 获取Json打印信息
///// </summary>
///// <param name="req"></param>
///// <returns></returns>
//public DataResult GetOpenJsonPrintInfo(OpenJsonPrintReq req);
/// <summary>
/// 获取Json打印信息
/// 获取Json打印信息文件流
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public DataResult GetOpenJsonPrintInfo(OpenJsonPrintReq req);
public DataResult<PrintStreamRes> GetOpenJsonPrintStream(OpenJsonPrintReq req);
}
}

@ -129,5 +129,40 @@ namespace DS.Module.PrintModule
return res;
}
/// <summary>
/// 获取Json打印信息
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public DataResult<PrintStreamRes> GetOpenJsonPrintStream(OpenJsonPrintReq req)
{
// 只要平台信息参数一致,多个请求只需设置一次参数
HttpUtillib.SetPlatformInfo(accessKey, accessSecret, ip, port, false);
//DataResult res = new DataResult();
// 发起POST请求超时时间15秒返回响应字节数组
string result = HttpUtillib.HttpPost(jsonPrintInfoUrl, JsonConvert.SerializeObject(req), 30);
if (null == result)
{
throw new Exception("请求失败,请联系管理员");
// 请求失败
// Console.WriteLine("/artemis/api/resource/v1/cameras/indexCode: POST fail");
}
else
{
var res = JsonConvert.DeserializeObject<DataResult>(result);
if (!res.Succeeded)
{
return DataResult<PrintStreamRes>.Failed(res.Message);
}
else
{
var printRes = JsonConvert.DeserializeObject<PrintStreamRes>(res.Data.ToString());
return DataResult<PrintStreamRes>.Success(printRes);
}
}
//return res;
}
}
}

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.Module.PrintModule
{
/// <summary>
/// 打印返回
/// </summary>
public class PrintStreamRes
{
/// <summary>
/// 打印类型
/// </summary>
public string PrintType { get; set; }
/// <summary>
/// 打印数据流
/// </summary>
public string PrintData { get; set; }
}
}

@ -382,7 +382,7 @@ public class InfoClient : BaseOrgModel<long>
/// <summary>
/// Desc:收单据模式
/// </summary>
[SugarColumn(ColumnDescription = "收单据模式")]
[SugarColumn(ColumnDescription = "收单据模式",DefaultValue ="0")]
public int? RCVMode { get; set; }
/// <summary>

@ -571,6 +571,10 @@ public class SeaExportRes
/// </summary>
public long SourceDetailId { get; set; }
/// <summary>
/// Desc:业务来源明细名称
/// </summary>
public string SourceDetailName { get; set; }
/// <summary>
/// Desc:报关票数
/// </summary>

@ -266,9 +266,9 @@ public class SeaExport : BaseOrgModel<long>
public long ReceiptPlaceId { get; set; }
/// <summary>
/// 装货港代码
/// 装货港Id
/// </summary>
[SugarColumn(ColumnDescription = "装货港代码", IsNullable = true)]
[SugarColumn(ColumnDescription = "装货港Id", IsNullable = true)]
public long LoadPortId { get; set; }
/// <summary>
@ -278,9 +278,9 @@ public class SeaExport : BaseOrgModel<long>
public string LoadPort { get; set; }
/// <summary>
/// 卸货港代码
/// 卸货港Id
/// </summary>
[SugarColumn(ColumnDescription = "卸货港代码", IsNullable = true)]
[SugarColumn(ColumnDescription = "卸货港Id", IsNullable = true)]
public long DischargePortId { get; set; }
/// <summary>

@ -14,6 +14,301 @@ public class SeaExportShippingBill : BaseModel<long>
/// 业务Id
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "业务Id", IsNullable = false, Length = 100)]
public long BusinessId { get; set; }
public long BusinessId { get; set; }
/// <summary>
/// 主提单号
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "主提单号", IsNullable = true, Length = 30)]
public string MBLNO { get; set; }
/// <summary>
/// 分提单号
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "分提单号", IsNullable = true, Length = 30)]
public string HBLNO { get; set; }
/// <summary>
/// 开船日期
/// </summary>
[SugarColumn(ColumnDescription = "开船日期", IsNullable = true)]
public DateTime? ETD { get; set; }
/// <summary>
/// 货代公司Id
/// </summary>
[SugarColumn(ColumnDescription = "货代公司Id", IsNullable = true, DefaultValue = "0")]
public long ForwarderId { get; set; }
/// <summary>
/// 货代公司
/// </summary>
[SugarColumn(ColumnDescription = "货代公司", IsNullable = true, Length = 100)]
public string Forwarder { get; set; }
/// <summary>
/// 船名 t_code_vessel
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "船名", IsNullable = true, Length = 60)]
public string Vessel { get; set; }
/// <summary>
/// 船名Id t_code_vessel
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "船名Id", IsNullable = true, DefaultValue = "0")]
public long VesselId { get; set; }
/// <summary>
/// 海关航次
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "海关航次", IsNullable = true, Length = 20)]
public string Voyno { get; set; }
/// <summary>
/// 内部航次
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "内部航次", IsNullable = true, Length = 20)]
public string InnerVoyno { get; set; }
/// <summary>
/// 船公司Id
/// </summary>
[SugarColumn(ColumnDescription = "船公司Id", IsNullable = true, DefaultValue = "0")]
public long CarrierId { get; set; }
/// <summary>
/// 船公司
/// </summary>
[SugarColumn(ColumnDescription = "船公司", IsNullable = true, Length = 100)]
public string Carrier { get; set; }
/// <summary>
/// 船公司名称
/// </summary>
[SugarColumn(ColumnDescription = "船公司名称", IsNullable = true, Length = 100)]
public string CarrierName { get; set; }
/// <summary>
/// 发货人 t_info_client CUSTNAME
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "发货人", IsNullable = true)]
public long? ShipperId { get; set; }
/// <summary>
/// 收货人 t_info_client CUSTNAME
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "收货人", IsNullable = true)]
public long? ConsigneeId { get; set; }
/// <summary>
/// 通知人 t_info_client CUSTNAME
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "通知人", IsNullable = true)]
public long? NotifyPartyId { get; set; }
/// <summary>
/// 发货人名称
/// </summary>
[SugarColumn(ColumnDescription = "发货人名称", IsNullable = true, Length = 50)]
public string ShipperName { get; set; }
/// <summary>
/// 发货人地址
/// </summary>
[SugarColumn(ColumnDescription = "发货人地址", IsNullable = true, Length = 100)]
public string ShipperAddress { get; set; }
/// <summary>
/// 发货人国家code
/// </summary>
[SugarColumn(ColumnDescription = "发货人国家code", IsNullable = true, Length = 50)]
public string ShipperCountry { get; set; }
/// <summary>
/// 发货人国家
/// </summary>
[SugarColumn(ColumnDescription = "发货人国家", IsNullable = true, Length = 50)]
public string ShipperCountryName { get; set; }
/// <summary>
/// 发货人电话
/// </summary>
[SugarColumn(ColumnDescription = "发货人电话", IsNullable = true, Length = 50)]
public string ShipperCountryTel { get; set; }
/// <summary>
/// 收货人名称
/// </summary>
[SugarColumn(ColumnDescription = "收货人名称", IsNullable = true, Length = 50)]
public string ConsigneeName { get; set; }
/// <summary>
/// 收货人地址
/// </summary>
[SugarColumn(ColumnDescription = "收货人地址", IsNullable = true, Length = 100)]
public string ConsigneeAddress { get; set; }
/// <summary>
/// 收货人国家code
/// </summary>
[SugarColumn(ColumnDescription = "收货人国家code", IsNullable = true, Length = 50)]
public string ConsigneeCountry { get; set; }
/// <summary>
/// 收货人国家
/// </summary>
[SugarColumn(ColumnDescription = "收货人国家", IsNullable = true, Length = 50)]
public string ConsigneeCountryName { get; set; }
/// <summary>
/// 收货人电话
/// </summary>
[SugarColumn(ColumnDescription = "收货人电话", IsNullable = true, Length = 50)]
public string ConsigneeCountryTel { get; set; }
/// <summary>
/// 通知人名称
/// </summary>
[SugarColumn(ColumnDescription = "通知人名称", IsNullable = true, Length = 50)]
public string NotifyPartyName { get; set; }
/// <summary>
/// 通知人地址
/// </summary>
[SugarColumn(ColumnDescription = "通知人地址", IsNullable = true, Length = 100)]
public string NotifyPartyAddress { get; set; }
/// <summary>
/// 通知人国家code
/// </summary>
[SugarColumn(ColumnDescription = "通知人国家code", IsNullable = true, Length = 50)]
public string NotifyPartyCountry { get; set; }
/// <summary>
/// 通知人国家
/// </summary>
[SugarColumn(ColumnDescription = "通知人国家", IsNullable = true, Length = 50)]
public string NotifyPartyCountryName { get; set; }
/// <summary>
/// 通知人电话
/// </summary>
[SugarColumn(ColumnDescription = "通知人电话", IsNullable = true, Length = 50)]
public string NotifyPartyCountryTel { get; set; }
/// <summary>
/// 装货港Id
/// </summary>
[SugarColumn(ColumnDescription = "装货港Id", IsNullable = true)]
public long LoadPortId { get; set; }
/// <summary>
/// 装货港代码
/// </summary>
[SugarColumn(ColumnDescription = "装货港代码", IsNullable = true, Length = 60)]
public string LoadPortCode { get; set; }
/// <summary>
/// 装货港
/// </summary>
[SugarColumn(ColumnDescription = "装货港", IsNullable = true, Length = 60)]
public string LoadPort { get; set; }
/// <summary>
/// 卸货港Id
/// </summary>
[SugarColumn(ColumnDescription = "卸货港Id", IsNullable = true)]
public long DischargePortId { get; set; }
/// <summary>
/// 卸货港代码
/// </summary>
[SugarColumn(ColumnDescription = "卸货港代码", IsNullable = true, Length = 60)]
public string DischargePortCode { get; set; }
/// <summary>
/// 卸货港
/// </summary>
[SugarColumn(ColumnDescription = "卸货港", IsNullable = true, Length = 60)]
public string DischargePort { get; set; }
/// <summary>
/// 收货地Id
/// </summary>
[SugarColumn(ColumnDescription = "收货地Id", IsNullable = true)]
public long DeliveryPlaceId { get; set; }
/// <summary>
/// 收货地代码
/// </summary>
[SugarColumn(ColumnDescription = "收货地代码", IsNullable = true, Length = 60)]
public string DeliveryPlaceCode { get; set; }
/// <summary>
/// 收货地
/// </summary>
[SugarColumn(ColumnDescription = "收货地", IsNullable = true, Length = 60)]
public string DeliveryPlace { get; set; }
/// <summary>
/// 场站Id t_crm_client CUSTNAME
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "场站Id", IsNullable = true, DefaultValue = "0")]
public long YardId { get; set; }
/// <summary>
/// 场站 t_crm_client CUSTNAME
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "场站", IsNullable = true, Length = 100)]
public string Yard { get; set; }
/// <summary>
/// 唛头 N/M
/// </summary>
[SugarColumn(ColumnDescription = "唛头", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
public string Marks { get; set; }
/// <summary>
/// 货物描述
/// </summary>
[SugarColumn(ColumnDescription = "货物描述", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
public string Description { get; set; }
/// <summary>
/// 货物标识 S/R/D/O
/// </summary>
[SugarColumn(ColumnDescription = "货物标识 S/R/D/O", IsNullable = true, Length = 1)]
public string CargoId { get; set; }
/// <summary>
/// 设置温度
/// </summary>
[SugarColumn(ColumnDescription = "设置温度", IsNullable = true, Length = 5)]
public string TemperatureSet { get; set; }
/// <summary>
/// 温度单位
/// </summary>
[SugarColumn(ColumnDescription = "温度单位", IsNullable = true, Length = 1)]
public string TemperatureUnit { get; set; }
/// <summary>
/// 冷藏通风量
/// </summary>
[SugarColumn(ColumnDescription = "冷藏通风量", IsNullable = true, Length = 10)]
public string ReeferQuantity { get; set; }
/// <summary>
/// 危险品分类
/// </summary>
[SugarColumn(ColumnDescription = "危险品分类", IsNullable = true, Length = 5)]
public string DangerClass { get; set; }
/// <summary>
/// 危险品编号
/// </summary>
[SugarColumn(ColumnDescription = "危险品编号", IsNullable = true, Length = 16)]
public string DangerNo { get; set; }
/// <summary>
/// 危险品联系人
/// </summary>
[SugarColumn(ColumnDescription = "危险品联系人", IsNullable = true, Length = 30)]
public string DangerAttn { get; set; }
/// <summary>
/// 危险品电话
/// </summary>
[SugarColumn(ColumnDescription = "危险品电话", IsNullable = true, Length = 30)]
public string DangerTel { get; set; }
/// <summary>
/// 包装 t_code_package
/// </summary>
[SugarColumn(ColumnDescription = "包装", IsNullable = true, Length = 20)]
public string KindPkgs { get; set; }
/// <summary>
/// Desc:备注
/// </summary>
[SugarColumn(ColumnDescription = "备注", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
public string Remark { get; set; }
/// <summary>
/// Desc:发送备注
/// </summary>
[SugarColumn(ColumnDescription = "发送备注", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
public string SendRemark { get; set; }
/// <summary>
/// 状态
/// </summary>
[SugarColumn(ColumnDescription = "状态", IsNullable = true, Length = 20)]
public string State { get; set; }
}

@ -227,7 +227,12 @@ public class SeaExportService : ISeaExportService
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<SeaExport>()
.Where(whereList)
.Select<SeaExportRes>().ToQueryPage(request.PageCondition);
.Select<SeaExportRes>()
.Mapper(it =>
{
it.SourceDetailName = tenantDb.Queryable<CodeSourceDetail>().Where(x => x.Id == it.SourceDetailId).Select(n => n.DetailName).First();
}
).ToQueryPage(request.PageCondition);
return data;
}
/// <summary>

@ -3,6 +3,7 @@ using DS.Module.ExcelModule;
using DS.Module.ExcelModule.Model;
using DS.Module.PrintModule;
using DS.WMS.Core.Code.Interface;
using LanguageExt.Common;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@ -54,9 +55,33 @@ namespace DS.WMS.MainApi.Controllers
/// <returns></returns>
[HttpPost]
[Route("GetOpenJsonPrintInfo")]
public DataResult GetOpenJsonPrintInfo([FromBody] OpenJsonPrintReq req)
public IActionResult GetOpenJsonPrintInfo([FromBody] OpenJsonPrintReq req)
{
return _invokeService.GetOpenJsonPrintInfo(req);
var res =_invokeService.GetOpenJsonPrintStream(req);
if (res.Succeeded)
{
var printData = res.Data.PrintData;
HttpContext.Response.Headers.Add("Content-Length", printData.Length.ToString());
HttpContext.Response.Headers.Add("Content-Type", "charset=UTF-8");
if (res.Data.PrintType =="1")
{
return File(printData, "application/octet-stream;charset=UTF-8", Path.GetFileName(Guid.NewGuid() + ".pdf"));
}
else if (res.Data.PrintType == "2")
{
return File(printData, "application/octet-stream;charset=UTF-8", Path.GetFileName(Guid.NewGuid() + ".xlsx"));
}
else
{
return File(printData, "application/octet-stream;charset=UTF-8", Path.GetFileName(Guid.NewGuid() + ".doc"));
}
}
else
{
throw new Exception(res.Message);
}
}
}
}

@ -131,3 +131,10 @@
2024-05-21 18:09:49.5712 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.OpApi\bin\Debug\net8.0\nlog.config
2024-05-21 18:09:49.5876 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-05-21 18:09:49.6178 Info Configuration initialized.
2024-05-22 14:54:32.8022 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-05-22 14:54:32.8562 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-05-22 14:54:32.8708 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-05-22 14:54:32.9005 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-05-22 14:54:32.9216 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.OpApi\bin\Debug\net8.0\nlog.config
2024-05-22 14:54:32.9334 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-05-22 14:54:32.9483 Info Configuration initialized.

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save