|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
using DS.Module.Core.Helpers;
|
|
|
|
|
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;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
|
|
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")]
|
|
|
|
|
[Obsolete]
|
|
|
|
|
public DataResult GetOpenPrintModuleList()
|
|
|
|
|
{
|
|
|
|
|
return _invokeService.GetOpenPrintModuleList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取打印模板列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Route("GetOpenPrintTemplateList")]
|
|
|
|
|
[Obsolete]
|
|
|
|
|
public DataResult GetOpenPrintTemplateList([FromQuery] string id)
|
|
|
|
|
{
|
|
|
|
|
return _invokeService.GetOpenPrintTemplateList(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取打印模板列表-异步
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Obsolete]
|
|
|
|
|
[Route("GetOpenPrintTemplateListAsync")]
|
|
|
|
|
public async Task<DataResult> GetOpenPrintTemplateListAsync([FromQuery] string id)
|
|
|
|
|
{
|
|
|
|
|
return await _invokeService.GetOpenPrintTemplateListAsync(id);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取Json打印信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="req"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[Obsolete]
|
|
|
|
|
[Route("GetOpenJsonPrintInfo")]
|
|
|
|
|
public DataResult GetOpenJsonPrintInfo([FromBody] OpenJsonPrintReq req)
|
|
|
|
|
{
|
|
|
|
|
var res =_invokeService.GetOpenJsonPrintInfo(req);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取Json打印信息-异步
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="req"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[Obsolete]
|
|
|
|
|
[Route("GetOpenJsonPrintInfoAsync")]
|
|
|
|
|
public async Task<DataResult> GetOpenJsonPrintInfoAsync([FromBody] OpenJsonPrintReq req)
|
|
|
|
|
{
|
|
|
|
|
var res = await _invokeService.GetOpenJsonPrintInfoAsync(req);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 获取Json打印信息Stream
|
|
|
|
|
///// </summary>
|
|
|
|
|
///// <param name="req"></param>
|
|
|
|
|
///// <returns></returns>
|
|
|
|
|
//[HttpPost]
|
|
|
|
|
//[Obsolete]
|
|
|
|
|
//[Route("GetOpenJsonPrintStream")]
|
|
|
|
|
//public IActionResult GetOpenJsonPrintStream([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");
|
|
|
|
|
// Byte[] info = Convert.FromBase64String(printData);
|
|
|
|
|
// if (res.Data.PrintType == "1")
|
|
|
|
|
// {
|
|
|
|
|
// return File(info, "application/octet-stream;charset=UTF-8", "test.pdf");
|
|
|
|
|
// }
|
|
|
|
|
// else if (res.Data.PrintType == "2")
|
|
|
|
|
// {
|
|
|
|
|
// return File(info, "application/octet-stream;charset=UTF-8", Guid.NewGuid() + ".xlsx");
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// return File(info, "application/octet-stream;charset=UTF-8", Guid.NewGuid() + ".doc");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// throw new Exception(res.Message);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取Json本地打印信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="req"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[Route("GetJsonPrintInfoAsync")]
|
|
|
|
|
public async Task<DataResult<string>> GetJsonPrintInfoAsync([FromBody] OpenJsonPrintReq req)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var url = AppSetting.Configuration["PrintService:LocalPrintUrl"];
|
|
|
|
|
if (url.IsNull())
|
|
|
|
|
return await Task.FromResult(DataResult<string>.Failed("未配置本地打印地址"));
|
|
|
|
|
|
|
|
|
|
var res = await RequestHelper.PostAsyncNoHeaders(url, req.ToJson());
|
|
|
|
|
var result = JsonConvert.DeserializeObject<DataResult<string>>(res);
|
|
|
|
|
if (result.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult<string>.Success(result.Message));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult<string>.Failed(result.Message));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|