1
huangxiaoqiang
2025-11-21 97a9ad53c6d1ac097f46f0b5d4d4d53547c9efe4
ÏîÄ¿´úÂë/Print/Print/Print/Controllers/PrintController.cs
@@ -3,6 +3,9 @@
using FastReport.Table;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Print.Controllers
{
@@ -12,8 +15,9 @@
    {
        const string PrintName = "Deli DL-888B(NEW)";
        [HttpGet, HttpPost, Route("PrintInboundOrder"), AllowAnonymous]
        public object PrintInboundOrder([FromBody] List<InboundOrder> inbounds)
        public object PrintInboundOrder([FromBody][ValidateNever] List<InboundOrder> inbounds)
        {
            Console.WriteLine($"{JsonSerializer.Serialize(inbounds)}");
            try
            {
                foreach (var inbound in inbounds)
@@ -64,7 +68,7 @@
                    TableCell QuantityObj = report.FindObject("Quantity") as TableCell;
                    if (QuantityObj != null)
                    {
                        QuantityObj.Text = inbound.Quantity.ToString();
                        QuantityObj.Text = inbound.Quantity.ToString("0");
                    }
                    TableCell ProductDrawingNumberObj = report.FindObject("ProductDrawingNumber") as TableCell;
                    if (ProductDrawingNumberObj != null)
@@ -81,14 +85,26 @@
                    {
                        WeightObj.Text = inbound.Weight.ToString();
                    }
                    TableCell DemandClassification = report.FindObject("DemandClassification") as TableCell;
                    if (DemandClassification != null)
                    {
                        if (inbound.DemandClassification == null || inbound.DemandClassification=="")
                        {
                            DemandClassification.Text = " ";
                        }
                        else
                        {
                            DemandClassification.Text = inbound.DemandClassification;
                        }
                    }
                    report.Print();
                    report.Dispose();
                }
                return new { code = 200, status = false };
                return new { Code = 200, Status = true , Message = "打印成功" };
            }
            catch (Exception ex)
            {
                return ex.Message;
                return new { Code = 400, Status = false, Message = "打印失败,请查看是否连接打印机" };
            }
        }
@@ -115,11 +131,11 @@
                    report.Print();
                    report.Dispose();
                }
                return new { code = 200, status = false };
                return new { Code = 400, Status = false, Message = "打印成功" };
            }
            catch (Exception ex)
            {
                return ex.Message;
                return new { Code = 400, Status = false, Message = "打印失败,请查看是否连接打印机" };
            }
        }
@@ -127,16 +143,17 @@
        public class InboundOrder
        {
            public string OrderNo { get; set; }
            public string? DemandClassification { get; set; }
            public string UpperOrderNo { get; set; }
            public string WarehouseName { get; set; }
            public string MaterialNo { get; set; }
            public string MaterialName { get; set; }
            public string Specs { get; set; }
            public string Unit { get; set; }
            public string? MaterialName { get; set; }
            public string? Specs { get; set; }
            public string? Unit { get; set; }
            public decimal Quantity { get; set; }
            public string ProductDrawingNumber { get; set; }
            public string Datetime { get; set; }
            public decimal Weight { get; set; }
            public string? ProductDrawingNumber { get; set; }
            public string? Datetime { get; set; }
            public decimal? Weight { get; set; }
        }
    }
}