添加项目文件。
This commit is contained in:
132
Print.Forum.HttpApi.Host/GoDEXPrintController.cs
Normal file
132
Print.Forum.HttpApi.Host/GoDEXPrintController.cs
Normal file
@ -0,0 +1,132 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Print.Application;
|
||||
using Volo.Abp.AspNetCore.Mvc;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
using Volo.Abp;
|
||||
using Print.Forum.Application.Contracts.JingGong.Abp.MES;
|
||||
using Print.Forum.Application.Contracts;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Print.Forum.HttpApi.Host
|
||||
{
|
||||
/// <summary>
|
||||
/// 打印实现
|
||||
/// </summary>
|
||||
[RemoteService]
|
||||
[Area("Print")]
|
||||
[Route("api/MES/[Controller]")]
|
||||
public class GoDEXPrintController : AbpController
|
||||
{
|
||||
private readonly ILogger<GoDEXPrintController> _logger;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 构造方法
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
public GoDEXPrintController(ILogger<GoDEXPrintController> logger, ICurrentTenant currentTenant)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打印图片文件
|
||||
/// </summary>
|
||||
/// <param name="goDEXPrintImageFile"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("PrintImageFile")]
|
||||
public ResultDto PrintImageFile(GoDEXPrintImageFile goDEXPrintImageFile)
|
||||
{
|
||||
if (goDEXPrintImageFile == null)
|
||||
return new ResultDto(false, $"参数{nameof(goDEXPrintImageFile)}不可为空!");
|
||||
|
||||
try
|
||||
{
|
||||
var godex = new GoDEXPrint();
|
||||
|
||||
godex.Print(goDEXPrintImageFile);
|
||||
|
||||
return new ResultDto(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"打印失败:{goDEXPrintImageFile}");
|
||||
|
||||
return new ResultDto(false, $"打印失败:{nameof(ex.Message)}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打印base64格式图片
|
||||
/// </summary>
|
||||
/// <param name="goDEXPrintBase64Image"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("PrintBase64Image")]
|
||||
public ResultDto PrintBase64Image(GoDEXPrintBase64Image goDEXPrintBase64Image)
|
||||
{
|
||||
if (goDEXPrintBase64Image == null)
|
||||
return new ResultDto(false, $"参数{nameof(goDEXPrintBase64Image)}不可为空!");
|
||||
|
||||
try
|
||||
{
|
||||
var godex = new GoDEXPrint();
|
||||
|
||||
godex.Print(goDEXPrintBase64Image);
|
||||
|
||||
return new ResultDto(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
return new ResultDto(false, $"打印失败:{nameof(ex.Message)}");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("PrintBase64Imagenew")]
|
||||
public async Task<ResultDto> PrintBase64Imagenew(PrintPictureDto input)
|
||||
{
|
||||
_logger.LogInformation("1.进入打印接口");
|
||||
//切换业务所属的租户
|
||||
|
||||
GoDEXPrintBase64Image goDEXPrintBase64Image = new GoDEXPrintBase64Image();
|
||||
goDEXPrintBase64Image.Communication = new GoDEXCommunication();
|
||||
goDEXPrintBase64Image.Communication.Host = input.ip;
|
||||
goDEXPrintBase64Image.Communication.Port = 9100;
|
||||
goDEXPrintBase64Image.LabelSetup = new GoDEXPrintSetup();
|
||||
goDEXPrintBase64Image.LabelSetup.Height = 70;
|
||||
goDEXPrintBase64Image.LabelSetup.Speed = 3;
|
||||
goDEXPrintBase64Image.LabelSetup.Width = 100;
|
||||
goDEXPrintBase64Image.LabelSetup.Dark = 10;
|
||||
goDEXPrintBase64Image.PosX = 3;
|
||||
goDEXPrintBase64Image.PosY = 3;
|
||||
goDEXPrintBase64Image.Width = 97;
|
||||
goDEXPrintBase64Image.Height = 67;
|
||||
goDEXPrintBase64Image.ImageBase64 = input.Base64Data.First();
|
||||
|
||||
if (goDEXPrintBase64Image == null)
|
||||
return new ResultDto(false, $"参数{nameof(goDEXPrintBase64Image)}不可为空!");
|
||||
|
||||
try
|
||||
{
|
||||
var godex = new GoDEXPrint();
|
||||
|
||||
godex.Print(goDEXPrintBase64Image);
|
||||
|
||||
return new ResultDto(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"打印失败:{JsonConvert.SerializeObject(goDEXPrintBase64Image)}");
|
||||
|
||||
return new ResultDto(false, $"打印失败:{nameof(ex.Message)}");
|
||||
}
|
||||
return new ResultDto(false, "");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user