|
|
|
|
using DS.Module.Core;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.MainApi.Controllers
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 打印服务 模块
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class PrintController : ApiController
|
|
|
|
|
{
|
|
|
|
|
private readonly IPrintService _invokeService;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 构造函数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="invokeService"></param>
|
|
|
|
|
public PrintController(IPrintService invokeService)
|
|
|
|
|
{
|
|
|
|
|
_invokeService = invokeService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取打印模块列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Route("GetOpenPrintModuleList")]
|
|
|
|
|
public DataResult GetOpenPrintModuleList()
|
|
|
|
|
{
|
|
|
|
|
return _invokeService.GetOpenPrintModuleList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取打印模板列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Route("GetOpenPrintTemplateList")]
|
|
|
|
|
public DataResult GetOpenPrintTemplateList([FromQuery] string id)
|
|
|
|
|
{
|
|
|
|
|
return _invokeService.GetOpenPrintTemplateList(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取Json打印信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="req"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[Route("GetOpenJsonPrintInfo")]
|
|
|
|
|
public IActionResult GetOpenJsonPrintInfo([FromBody] OpenJsonPrintReq 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|