| | |
| | | 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 |
| | | { |
| | | [ApiController] |
| | | [Route("[controller]")] |
| | | public class PrintController : Controller |
| | | {//{ |
| | | // private readonly IPrintService _print; |
| | | // public PrintController(IPrintService print) |
| | | // { |
| | | // _print = print; |
| | | // } |
| | | { |
| | | const string PrintName = "Deli DL-888B(NEW)"; |
| | | [HttpGet, HttpPost, Route("PrintInboundOrder"), AllowAnonymous] |
| | | public object PrintInboundOrder([FromBody] InboundOrder inbound) |
| | | public object PrintInboundOrder([FromBody][ValidateNever] List<InboundOrder> inbounds) |
| | | { |
| | | Console.WriteLine($"{JsonSerializer.Serialize(inbounds)}"); |
| | | try |
| | | { |
| | | string ReportPathmater = System.IO.Directory.GetCurrentDirectory(); |
| | | string MFile = string.Empty; |
| | | MFile = ReportPathmater + "\\frx\\MaterMode.frx"; |
| | | Report report = new Report(); |
| | | report.Load(MFile); |
| | | report.PrintSettings.ShowDialog = false; |
| | | System.Drawing.Printing.PrinterSettings oitem = new System.Drawing.Printing.PrinterSettings(); |
| | | BarcodeObject OrderNoObj = report.FindObject("OrderNo") as BarcodeObject; |
| | | if (OrderNoObj != null) |
| | | foreach (var inbound in inbounds) |
| | | { |
| | | OrderNoObj.Text = inbound.OrderNo; |
| | | string ReportPathmater = System.IO.Directory.GetCurrentDirectory(); |
| | | string MFile = string.Empty; |
| | | MFile = ReportPathmater + "\\frx\\InboundOrder.frx"; |
| | | Report report = new Report(); |
| | | report.Load(MFile); |
| | | report.PrintSettings.ShowDialog = false; |
| | | System.Drawing.Printing.PrinterSettings oitem = new System.Drawing.Printing.PrinterSettings(); |
| | | report.PrintSettings.Printer = PrintName; |
| | | BarcodeObject OrderNoObj = report.FindObject("OrderNo") as BarcodeObject; |
| | | if (OrderNoObj != null) |
| | | { |
| | | OrderNoObj.Text = inbound.OrderNo; |
| | | } |
| | | TableCell UpperOrderNoObj = report.FindObject("UpperOrderNo") as TableCell; |
| | | if (UpperOrderNoObj != null) |
| | | { |
| | | UpperOrderNoObj.Text = inbound.UpperOrderNo; |
| | | } |
| | | TableCell WarehouseNameObj = report.FindObject("WarehouseName") as TableCell; |
| | | if (WarehouseNameObj != null) |
| | | { |
| | | WarehouseNameObj.Text = inbound.WarehouseName; |
| | | } |
| | | TableCell MaterialNoObj = report.FindObject("MaterialNo") as TableCell; |
| | | if (MaterialNoObj != null) |
| | | { |
| | | MaterialNoObj.Text = inbound.MaterialNo; |
| | | } |
| | | TableCell MaterialNameObj = report.FindObject("MaterialName") as TableCell; |
| | | if (MaterialNameObj != null) |
| | | { |
| | | MaterialNameObj.Text = inbound.MaterialName; |
| | | } |
| | | TableCell SpecsObj = report.FindObject("Specs") as TableCell; |
| | | if (SpecsObj != null) |
| | | { |
| | | SpecsObj.Text = inbound.Specs; |
| | | } |
| | | TableCell UnitObj = report.FindObject("Unit") as TableCell; |
| | | if (UnitObj != null) |
| | | { |
| | | UnitObj.Text = inbound.Unit; |
| | | } |
| | | TableCell QuantityObj = report.FindObject("Quantity") as TableCell; |
| | | if (QuantityObj != null) |
| | | { |
| | | QuantityObj.Text = inbound.Quantity.ToString("0"); |
| | | } |
| | | TableCell ProductDrawingNumberObj = report.FindObject("ProductDrawingNumber") as TableCell; |
| | | if (ProductDrawingNumberObj != null) |
| | | { |
| | | ProductDrawingNumberObj.Text = inbound.ProductDrawingNumber; |
| | | } |
| | | TableCell DatetimeObj = report.FindObject("Datetime") as TableCell; |
| | | if (DatetimeObj != null) |
| | | { |
| | | DatetimeObj.Text = inbound.Datetime; |
| | | } |
| | | TableCell WeightObj = report.FindObject("Weight") as TableCell; |
| | | if (WeightObj != null) |
| | | { |
| | | 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(); |
| | | } |
| | | TableCell UpperOrderNoObj = report.FindObject("UpperOrderNo") as TableCell; |
| | | if (UpperOrderNoObj != null) |
| | | { |
| | | UpperOrderNoObj.Text = inbound.UpperOrderNo; |
| | | } |
| | | TableCell WarehouseNameObj = report.FindObject("WarehouseName") as TableCell; |
| | | if (WarehouseNameObj != null) |
| | | { |
| | | WarehouseNameObj.Text = inbound.WarehouseName; |
| | | } |
| | | TableCell MaterialNoObj = report.FindObject("MaterialNo") as TableCell; |
| | | if (MaterialNoObj != null) |
| | | { |
| | | MaterialNoObj.Text = inbound.MaterialNo; |
| | | } |
| | | TableCell MaterialNameObj = report.FindObject("MaterialName") as TableCell; |
| | | if (MaterialNameObj != null) |
| | | { |
| | | MaterialNameObj.Text = inbound.MaterialName; |
| | | } |
| | | TableCell SpecsObj = report.FindObject("Specs") as TableCell; |
| | | if (SpecsObj != null) |
| | | { |
| | | SpecsObj.Text = inbound.Specs; |
| | | } |
| | | TableCell UnitObj = report.FindObject("Unit") as TableCell; |
| | | if (UnitObj != null) |
| | | { |
| | | UnitObj.Text = inbound.Unit; |
| | | } |
| | | TableCell QuantityObj = report.FindObject("Quantity") as TableCell; |
| | | if (QuantityObj != null) |
| | | { |
| | | QuantityObj.Text = inbound.Quantity.ToString(); |
| | | } |
| | | TableCell ProductDrawingNumberObj = report.FindObject("ProductDrawingNumber") as TableCell; |
| | | if (ProductDrawingNumberObj != null) |
| | | { |
| | | ProductDrawingNumberObj.Text = inbound.ProductDrawingNumber; |
| | | } |
| | | TableCell DatetimeObj = report.FindObject("Datetime") as TableCell; |
| | | if (DatetimeObj != null) |
| | | { |
| | | DatetimeObj.Text = inbound.Datetime; |
| | | } |
| | | TableCell WeightObj = report.FindObject("Weight") as TableCell; |
| | | if (WeightObj != null) |
| | | { |
| | | WeightObj.Text = inbound.Weight.ToString(); |
| | | } |
| | | report.Print(); |
| | | report.Dispose(); |
| | | return true; |
| | | 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 = "æå°å¤±è´¥ï¼è¯·æ¥çæ¯å¦è¿æ¥æå°æº" }; |
| | | } |
| | | } |
| | | |
| | | [HttpGet, HttpPost, Route("PrintPalletCode"), AllowAnonymous] |
| | | public object PrintPalletCode([FromBody] List<string> PalletCodes) |
| | | { |
| | | try |
| | | { |
| | | foreach (var item in PalletCodes) |
| | | { |
| | | string ReportPathmater = System.IO.Directory.GetCurrentDirectory(); |
| | | string MFile = string.Empty; |
| | | MFile = ReportPathmater + "\\frx\\PalletCode.frx"; |
| | | Report report = new Report(); |
| | | report.Load(MFile); |
| | | report.PrintSettings.ShowDialog = false; |
| | | System.Drawing.Printing.PrinterSettings oitem = new System.Drawing.Printing.PrinterSettings(); |
| | | report.PrintSettings.Printer = PrintName; |
| | | BarcodeObject OrderNoObj = report.FindObject("PalletCode") as BarcodeObject; |
| | | if (OrderNoObj != null) |
| | | { |
| | | OrderNoObj.Text = item; |
| | | } |
| | | report.Print(); |
| | | report.Dispose(); |
| | | } |
| | | return new { Code = 400, Status = false, Message = "æå°æå" }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return new { Code = 400, Status = false, Message = "æå°å¤±è´¥ï¼è¯·æ¥çæ¯å¦è¿æ¥æå°æº" }; |
| | | } |
| | | } |
| | | |
| | | |
| | | 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; } |
| | | } |
| | | } |
| | | |
| | | } |