From add4308b91ae89f72bd8f1dc7f704b72de712469 Mon Sep 17 00:00:00 2001 From: Tyrone CT Date: Wed, 29 Apr 2026 09:52:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9B=BA=E4=BD=93=E9=A5=AE?= =?UTF-8?q?=E6=96=99=E6=89=B9=E5=8F=B7=E5=88=9D=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FATrace.App/Program.cs | 14 +++ FATrace.App/ZebraPrint.cs | 109 ++++++++++++++---- FATrace.App/frmMain.Designer.cs | 48 ++++++-- FATrace.App/frmMain.cs | 67 ++++++++++- FATrace.Com/NVRCom.cs | 84 +++++++++----- FATrace.Com/ParsedCodeInfo.cs | 1 + FATrace.Model/QRModel.cs | 26 +++-- FATrace.Model/RawProInput.cs | 6 + FATrace.Model/RawProUse.cs | 6 + .../CsvModel/RawProUserCsvDtoMap.cs | 19 +-- FATrace.WPLApp/ModelDto/RawProInputDto.cs | 1 + FATrace.WPLApp/ModelDto/RawProUseDto.cs | 5 + FATrace.WPLApp/ModelDto/RawProUserCsvDto.cs | 5 + .../ViewModels/RawProInputViewModel.cs | 11 +- .../ViewModels/RawProUseViewModel.cs | 15 ++- FATrace.WPLApp/Views/RawProInputView.xaml | 12 ++ FATrace.WPLApp/Views/RawProUseView.xaml | 15 ++- 17 files changed, 354 insertions(+), 90 deletions(-) diff --git a/FATrace.App/Program.cs b/FATrace.App/Program.cs index abef797..da41899 100644 --- a/FATrace.App/Program.cs +++ b/FATrace.App/Program.cs @@ -1,4 +1,5 @@ using NLog; +using FATrace.Model; namespace FATrace.App { @@ -42,6 +43,19 @@ namespace FATrace.App // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); + + // 结构同步:App 端当前 UseAutoSyncStructure(false),需要显式同步新增列 + try + { + FSqlContext.FDb.CodeFirst.SyncStructure(); + FSqlContext.FDb.CodeFirst.SyncStructure(); + } + catch (Exception ex) + { + logger.Error(ex, "数据库结构同步失败"); + MessageBox.Show($"数据库结构同步失败:{ex.Message}"); + } + Application.Run(new frmMain()); } diff --git a/FATrace.App/ZebraPrint.cs b/FATrace.App/ZebraPrint.cs index 4523888..6ca2b22 100644 --- a/FATrace.App/ZebraPrint.cs +++ b/FATrace.App/ZebraPrint.cs @@ -86,10 +86,63 @@ namespace FATrace.App } } + ///// + ///// 打印称重信息 + ///// + //public void PrintWeight(string Code, string RawName, double Weight, string Batch, string SolidBeveBatch, int ShelfLife) + //{ + // ////二维码数据 + // //var Code = new StringBuilder(); + // //Code.Append(Batch); + // //Code.Append(','); + // //Code.Append(Weight.ToString().Replace(".", "")); + // //Code.Append(','); + // //Code.Append(ShelfLife.ToString()); + // //Code.Append(','); + // //Code.Append(GetSourceInf(Source)); + // //Code.Append(','); + // //Code.Append(DayCount.ToString()); + + // var RawNameUnicodeZplStr = UnicodeToZPLHelper.CompressZPL(RawName, "RawName", new Font("宋体", 26f, FontStyle.Bold), TextDirection.Degree0); + + // var PrintZpl = new StringBuilder(); + + // PrintZpl.AppendLine("~DGRawNameCN.GRF,1647,27,k0Y01K08K08M08R01g038J0EK0FL01CP0601CR0EL07CJ0FK0FL01FO01F01ER0OFJ0EK0EL03CO0HF83CR07R0EK0EL038N0HF803CR07I03N0E1J0EL078I0CI0HFCH038R07I07CK040E186H0EL07I01EH0101CH078R07I07L060E3E380EL0LF8I01CH07S07I06L070E381E0EL0EI01EJ01CH07I02O07I0CH02I038E3H0F0EK01CI03CJ01CH0EI07O070608H07I038E7H0F0EK038I078J01CH0KF8N0707KF8H03CE6H070EK07J078J01CH0EI0F8N0707J07I018E4H070EK07J0FK01CE1CI0EO0707J07I018ECH020EK0FCH01EK01DE18181CO0707J07K0E8J0EJ01CFH03CI03JFB81E18O0707J07K0E18I0EJ03078078K03C0301C3P0707J07K0E3CI0EJ0603C0FL03C0601C2P0707KFH01KFI0EJ0C03C1EL03C0601CQ0707J07J01EH06H0EI01801C3CL07C0C01CQ0707J07J03EH0380EI02H01878L07F0801CQ0707J07J03EH03C0EN0FM07D8061CQ0707J07J03FH01E0EM01EM0FDE079D8P0707J07J07FCH0F0EM07CM0FCF0F1HCP0607J07J07EFH0E0EM0FM01DC70F1C6P0607KFJ07E78060EL0DEI03I01DC70E1C7P060701C07J0HE3C060E3K0F8I038H039C31E1C38O0E0601C06J0CE1CI0E38I01LFCH039C31C1C38O0EI01CK01CE1CI0E7CI03EJ038H071C01C1C1CO0EI01CK018E08I0FCJ0FEJ038H061C0381C1EO0EH0C1CK030EI03FEJ03CEJ038H0E1C0301C0FO0EH0E1HCJ070EH07F0EJ0F0EJ038H0C1C0701C0FO0C01F1C78I060E3FCH0EI03C0EJ0380181C0601C078N0C03C1C1EI0C0E0CI0EI0EH0EJ0380301C0C01C078M01C0781C0F80180EK0EH03I0EJ0380201C1801C038M01C0F01C07E01H0EK0EL0EJ038I01C1801C038M0181C01C03F02H0EK0EL0EJ038I01C3H01C03N0383801CH0FJ0EK0EL0EJ038I01C6H01CP0307H01CH0FJ0EK0EL0EJ038I01CI01CP060C063CH07J0EK0EL0EJ038I01CH0E1CP061803FCH03J0EK0EL0LF8I01CH03FCP0C2I0F8M0EK0EL0EJ038I01CH01F8P08J078M0EK0EL0EJ03J01CI0FP01K02N0CK0EL0CO01J06g0K08K08z0z0h0"); + // PrintZpl.AppendLine("~DGWeightCN.GRF,407,11,h0P06L01S07FI0JF8O03HF8J0CH01R01K0JFR01H0CH0CH01P0KFEH0CH01R01K0JFR0102I0CH01P01JFM018N01810201LFC06L018102P0FL018102I0JF8H06L01IFEI0C0818O018102I0C0818O018103I0C0818O01JFI0JF8O018103I0C0818Q01K0JF8Q01018H0C081P07JFCJ08S01M080CH06N01J03JFEH0FN01H07J08J06K03LF8I08018U0LFCq0L0"); + // PrintZpl.AppendLine("~DGBatchCN.GRF,407,11,g0J01g0G01CO01P018608I07IF8O01870EI06H03P01860CI06H03P01B60CI06H03O03HFE0CI06H03P01860CI06H03P01860C3H07IFP018H6C7806H03P0187FC6O06L01BE0HCL03H0FL01E60FH0LF806L03860EJ0CQ01F860CJ0CQ039860CI018018N0H1860CI03IFCO01860CI01H018O01860CL038O01860C1K03P01861C1K03P018H6C1K03I06L0186HC1K03I0FL01878C1I0106I06K01F870E38I0FEP070207FJ03CP02O03p0M0"); + // PrintZpl.AppendLine("~DGShelfLifeCN.GRF,814,22,h0M04O018g0R07I08K0FEH0C1M08K0806R0E7HFC0107F8I0E18H08H01801IFC03R0C601801F8K0C18HFCH03H018018018Q0C601801807J0C18C0CH06H018018H08P018601801806I07IFC0CH04H018018H0CP01860180180606H0C18C0CH0CH018018H06P030601801KFH0C18C0CH08H018018H06P038601801806J0C18C0C018H01IF8H03P0707HF801806J0HF8HFC018H018018H03P07063180180608H0C18C0C03I018018H03I06L0DH03I019IFCH0C18C0C03I018018H03I0FL09H03I0198H08H0C18C0C03I018018H03I06K0H1H03030198408H0HF8C0C03I018018H03O0217JF8198708H0C18C0C03I018018H03P01H07I0198608H0C18HFC03I01IF8H03P01H0F4H0H18608H0C1HC0C03I018018H03P01H0F6H031860C07IFC0C018H03H018H03P0101B2H031860CK0C0C018H03H018H03P010I3H0318C0CH0620C0C018H03H018H06P010H3180218C08H073980CH0CH03H018H06P010631C0601F8I0E1D80CH04H06H018H0CI06L010C30E0401878H0C0DH0CH06H06H018H08I0FL0H18307H80701E0180BH0CH03H0CH018018I06L0130302080CH0E02H060F8H0181803F803Q01403H0103I0604H0C038I083I07806Q03H02J0CI02I01H01K04I02z0N0"); + // PrintZpl.AppendLine("^XA\r\n~TA000\r\n~JSN\r\n^LT0\r\n^MNW\r\n^MTT\r\n^PON\r\n^PMN\r\n^LH0,0\r\n^JMA\r\n^PR4,4\r\n~SD15\r\n^JUS\r\n^LRN\r\n^CI27\r\n^PA0,1,1,0\r\n^XZ\r\n^XA\r\n^MMT\r\n^PW472\r\n^LL354\r\n^LS0\r\n^FT275,366^BQN,2,7\r\n^FH\\^FDLA,"); + // PrintZpl.AppendLine(Code.ToString()); + // PrintZpl.AppendLine("^FS\r\n^FO150,10^XG"); + // PrintZpl.AppendLine("RawNameCN"); + // PrintZpl.AppendLine("^Fs"); + // PrintZpl.AppendLine("^FO110,65^GFA,"); + // PrintZpl.AppendLine(RawNameUnicodeZplStr); + // PrintZpl.AppendLine("^FS\r\n^FO8,166^XG"); + // PrintZpl.AppendLine("WeightCN"); + // PrintZpl.AppendLine("^Fs\r\n^FT89,191^A0N,29,48^FH\\^CI28^FD"); + // PrintZpl.AppendLine(Weight.ToString() + "g"); + // PrintZpl.AppendLine("^FS^CI27\r\n^FO8,215^XG"); + // PrintZpl.AppendLine("BatchCN"); + // PrintZpl.AppendLine("^Fs\r\n^FT92,241^A0N,29,41^FH\\^CI28^FD"); + // PrintZpl.AppendLine(Batch); + // PrintZpl.AppendLine("^FS^CI27\r\n^FO8,267^XG"); + // PrintZpl.AppendLine("ShelfLifeCN"); + // PrintZpl.AppendLine("^Fs\r\n^FO4,3^GB465,0,4^FS\r\n^FO2,3^GB0,349,4^FS\r\n^FO5,348^GB464,0,4^FS\r\n^FO467,3^GB0,349,4^FS\r\n^FT25,125^A0N,28,30^FH\\^CI28^FD"); + // PrintZpl.AppendLine(Code.ToString()); + // PrintZpl.AppendLine("^FS^CI27\r\n^FT175,293^A0N,28,48^FH\\^CI28^FD"); + // PrintZpl.AppendLine(ShelfLife.ToString()); + // PrintZpl.AppendLine("^FS^CI27\r\n^PQ1,0,1,Y\r\n^XZ"); + // //var dd= PrintZpl.ToString(); + + // this.PrintZpl(PrintZpl.ToString()); + //} + + /// /// 打印称重信息 /// - public void PrintWeight(string Code, string RawName, double Weight, string Batch, int ShelfLife) + public void PrintWeight(string Code,string SimpleCode, string RawName, double Weight, string Batch, string SolidBeveBatch, int ShelfLife) { ////二维码数据 //var Code = new StringBuilder(); @@ -103,36 +156,44 @@ namespace FATrace.App //Code.Append(','); //Code.Append(DayCount.ToString()); - var RawNameUnicodeZplStr = UnicodeToZPLHelper.CompressZPL(RawName, "RawName", new Font("宋体", 22f, FontStyle.Bold), TextDirection.Degree0); + var RawNameUnicodeZplStr = UnicodeToZPLHelper.CompressZPL(RawName, "RawNameCN", new Font("宋体", 26f, FontStyle.Bold), TextDirection.Degree0); var PrintZpl = new StringBuilder(); - PrintZpl.AppendLine("~DGRawNameCN.GRF,1647,27,k0Y01K08K08M08R01g038J0EK0FL01CP0601CR0EL07CJ0FK0FL01FO01F01ER0OFJ0EK0EL03CO0HF83CR07R0EK0EL038N0HF803CR07I03N0E1J0EL078I0CI0HFCH038R07I07CK040E186H0EL07I01EH0101CH078R07I07L060E3E380EL0LF8I01CH07S07I06L070E381E0EL0EI01EJ01CH07I02O07I0CH02I038E3H0F0EK01CI03CJ01CH0EI07O070608H07I038E7H0F0EK038I078J01CH0KF8N0707KF8H03CE6H070EK07J078J01CH0EI0F8N0707J07I018E4H070EK07J0FK01CE1CI0EO0707J07I018ECH020EK0FCH01EK01DE18181CO0707J07K0E8J0EJ01CFH03CI03JFB81E18O0707J07K0E18I0EJ03078078K03C0301C3P0707J07K0E3CI0EJ0603C0FL03C0601C2P0707KFH01KFI0EJ0C03C1EL03C0601CQ0707J07J01EH06H0EI01801C3CL07C0C01CQ0707J07J03EH0380EI02H01878L07F0801CQ0707J07J03EH03C0EN0FM07D8061CQ0707J07J03FH01E0EM01EM0FDE079D8P0707J07J07FCH0F0EM07CM0FCF0F1HCP0607J07J07EFH0E0EM0FM01DC70F1C6P0607KFJ07E78060EL0DEI03I01DC70E1C7P060701C07J0HE3C060E3K0F8I038H039C31E1C38O0E0601C06J0CE1CI0E38I01LFCH039C31C1C38O0EI01CK01CE1CI0E7CI03EJ038H071C01C1C1CO0EI01CK018E08I0FCJ0FEJ038H061C0381C1EO0EH0C1CK030EI03FEJ03CEJ038H0E1C0301C0FO0EH0E1HCJ070EH07F0EJ0F0EJ038H0C1C0701C0FO0C01F1C78I060E3FCH0EI03C0EJ0380181C0601C078N0C03C1C1EI0C0E0CI0EI0EH0EJ0380301C0C01C078M01C0781C0F80180EK0EH03I0EJ0380201C1801C038M01C0F01C07E01H0EK0EL0EJ038I01C1801C038M0181C01C03F02H0EK0EL0EJ038I01C3H01C03N0383801CH0FJ0EK0EL0EJ038I01C6H01CP0307H01CH0FJ0EK0EL0EJ038I01CI01CP060C063CH07J0EK0EL0EJ038I01CH0E1CP061803FCH03J0EK0EL0LF8I01CH03FCP0C2I0F8M0EK0EL0EJ038I01CH01F8P08J078M0EK0EL0EJ03J01CI0FP01K02N0CK0EL0CO01J06g0K08K08z0z0h0"); - PrintZpl.AppendLine("~DGWeightCN.GRF,407,11,h0P06L01S07FI0JF8O03HF8J0CH01R01K0JFR01H0CH0CH01P0KFEH0CH01R01K0JFR0102I0CH01P01JFM018N01810201LFC06L018102P0FL018102I0JF8H06L01IFEI0C0818O018102I0C0818O018103I0C0818O01JFI0JF8O018103I0C0818Q01K0JF8Q01018H0C081P07JFCJ08S01M080CH06N01J03JFEH0FN01H07J08J06K03LF8I08018U0LFCq0L0"); - PrintZpl.AppendLine("~DGBatchCN.GRF,407,11,g0J01g0G01CO01P018608I07IF8O01870EI06H03P01860CI06H03P01B60CI06H03O03HFE0CI06H03P01860CI06H03P01860C3H07IFP018H6C7806H03P0187FC6O06L01BE0HCL03H0FL01E60FH0LF806L03860EJ0CQ01F860CJ0CQ039860CI018018N0H1860CI03IFCO01860CI01H018O01860CL038O01860C1K03P01861C1K03P018H6C1K03I06L0186HC1K03I0FL01878C1I0106I06K01F870E38I0FEP070207FJ03CP02O03p0M0"); - PrintZpl.AppendLine("~DGShelfLifeCN.GRF,814,22,h0M04O018g0R07I08K0FEH0C1M08K0806R0E7HFC0107F8I0E18H08H01801IFC03R0C601801F8K0C18HFCH03H018018018Q0C601801807J0C18C0CH06H018018H08P018601801806I07IFC0CH04H018018H0CP01860180180606H0C18C0CH0CH018018H06P030601801KFH0C18C0CH08H018018H06P038601801806J0C18C0C018H01IF8H03P0707HF801806J0HF8HFC018H018018H03P07063180180608H0C18C0C03I018018H03I06L0DH03I019IFCH0C18C0C03I018018H03I0FL09H03I0198H08H0C18C0C03I018018H03I06K0H1H03030198408H0HF8C0C03I018018H03O0217JF8198708H0C18C0C03I018018H03P01H07I0198608H0C18HFC03I01IF8H03P01H0F4H0H18608H0C1HC0C03I018018H03P01H0F6H031860C07IFC0C018H03H018H03P0101B2H031860CK0C0C018H03H018H03P010I3H0318C0CH0620C0C018H03H018H06P010H3180218C08H073980CH0CH03H018H06P010631C0601F8I0E1D80CH04H06H018H0CI06L010C30E0401878H0C0DH0CH06H06H018H08I0FL0H18307H80701E0180BH0CH03H0CH018018I06L0130302080CH0E02H060F8H0181803F803Q01403H0103I0604H0C038I083I07806Q03H02J0CI02I01H01K04I02z0N0"); - PrintZpl.AppendLine("^XA\r\n~TA000\r\n~JSN\r\n^LT0\r\n^MNW\r\n^MTT\r\n^PON\r\n^PMN\r\n^LH0,0\r\n^JMA\r\n^PR4,4\r\n~SD15\r\n^JUS\r\n^LRN\r\n^CI27\r\n^PA0,1,1,0\r\n^XZ\r\n^XA\r\n^MMT\r\n^PW472\r\n^LL354\r\n^LS0\r\n^FT275,366^BQN,2,7\r\n^FH\\^FDLA,"); - PrintZpl.AppendLine(Code.ToString()); - PrintZpl.AppendLine("^FS\r\n^FO150,10^XG"); - PrintZpl.AppendLine("RawNameCN"); - PrintZpl.AppendLine("^Fs"); - PrintZpl.AppendLine("^FO110,65^GFA,"); + PrintZpl.AppendLine("~DGBatchCN.GRF,315,9,g0718M018L079E38H01IFCL070C3CH01801CL070C38H01801CL030C38H01801CL036C38H01801CK07HFC39C01801CL030DB9E01IFCL030HFB8018018L030C3FL018K037C3E03KFCK03HC38I07O0F0C38I07N07F0C38I07N03B0C38I0EH0CL030C38H01IFEL030C38I0C01CL030C78CJ01CL030CF8CJ01CL030FB8CJ01CL031F38CJ038K03F1E39EI0C38L0F0C3FCI0HF8L0EN03FV01Cn0M0"); + PrintZpl.AppendLine("~DGShelfLifeCN.GRF,420,12,g0L01CO0EH0618M01EH02K0HFH079HC18J01DIF806HF8I071CHFCJ039C07H0783J071HE1CJ039C07H0603CH03IFE1CJ031C07H060383H071CE1CJ071C07H07JF8071CE1CJ061C07H06038I071CE1CJ0F1C07H06038I07FCHFCJ0F1IFH060384H071CE1CI01F1CE7H067IFH071CE1CI03FH0EI0H6H0EH07FCE1CI037H0E0C0H630EH071CE1CI067JFE0E63CEH071CE1CJ0703FI0E638EH071EHFCJ0703F8H0E638E03IFE1CJ0707F8H0E638EH03H0E1CJ0707FCH0C630EH03B0E1CJ070IE01C670EH07HDC1CJ071CE701C67CI071DC1CJ0718E78180E78H0E0F81CJ0730E3E381C1F01C0F81CJ0760E1C30380F818071FCJ07C0EH060EH0783H0E078J06H0CI078H030601C03p0Y0"); + + PrintZpl.AppendLine("^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR6,6~SD15^JUS^LRN^CI0^XZ\r\n^XA\r\n^MMT\r\n^PW472\r\n^LL0354\r\n^LS0"); + PrintZpl.AppendLine("^FO30,12^XG"); PrintZpl.AppendLine(RawNameUnicodeZplStr); - PrintZpl.AppendLine("^FS\r\n^FO8,166^XG"); - PrintZpl.AppendLine("WeightCN"); - PrintZpl.AppendLine("^Fs\r\n^FT89,191^A0N,29,48^FH\\^CI28^FD"); - PrintZpl.AppendLine(Weight.ToString() + "g"); - PrintZpl.AppendLine("^FS^CI27\r\n^FO8,215^XG"); + PrintZpl.AppendLine("^Fs"); + + PrintZpl.AppendLine("^FO68,128^XG"); PrintZpl.AppendLine("BatchCN"); - PrintZpl.AppendLine("^Fs\r\n^FT92,241^A0N,29,41^FH\\^CI28^FD"); - PrintZpl.AppendLine(Batch); - PrintZpl.AppendLine("^FS^CI27\r\n^FO8,267^XG"); + PrintZpl.AppendLine("^Fs"); + PrintZpl.AppendLine("^FO20,180^A0N,30,30^FD"); + PrintZpl.AppendLine(SolidBeveBatch); + PrintZpl.AppendLine("^FS"); + PrintZpl.AppendLine("^FO50,240^XG"); PrintZpl.AppendLine("ShelfLifeCN"); - PrintZpl.AppendLine("^Fs\r\n^FO4,3^GB465,0,4^FS\r\n^FO2,3^GB0,349,4^FS\r\n^FO5,348^GB464,0,4^FS\r\n^FO467,3^GB0,349,4^FS\r\n^FT25,125^A0N,28,30^FH\\^CI28^FD"); - PrintZpl.AppendLine(Code.ToString()); - PrintZpl.AppendLine("^FS^CI27\r\n^FT175,293^A0N,28,48^FH\\^CI28^FD"); + PrintZpl.AppendLine("^Fs"); + PrintZpl.AppendLine("^FO1,3^GB4,348,4^FS"); + PrintZpl.AppendLine("^FO64,62^A0N,30,30^FD"); + PrintZpl.AppendLine(SimpleCode); + PrintZpl.AppendLine("^FS"); + PrintZpl.AppendLine("^FO78,288^A0N,40,40^FD"); PrintZpl.AppendLine(ShelfLife.ToString()); - PrintZpl.AppendLine("^FS^CI27\r\n^PQ1,0,1,Y\r\n^XZ"); + PrintZpl.AppendLine("^FS"); + PrintZpl.AppendLine("^FT246,350^BQN,2,7"); + PrintZpl.AppendLine("^FH\\^FDLA,"); + PrintZpl.AppendLine(Code); + PrintZpl.AppendLine("^FS"); + PrintZpl.AppendLine("^FO4,3^GB465,4,4^FS\r\n"); + PrintZpl.AppendLine("^FO5,348^GB464,4,4^FS"); + PrintZpl.AppendLine("^FO467,3^GB4,349,4^FS"); + PrintZpl.AppendLine("^FO5,103^GB461,4,4^FS"); + PrintZpl.AppendLine("^PQ1,0,1,Y^XZ"); + //var dd= PrintZpl.ToString(); this.PrintZpl(PrintZpl.ToString()); diff --git a/FATrace.App/frmMain.Designer.cs b/FATrace.App/frmMain.Designer.cs index 11cb372..0c97780 100644 --- a/FATrace.App/frmMain.Designer.cs +++ b/FATrace.App/frmMain.Designer.cs @@ -114,6 +114,8 @@ namespace FATrace.App dtpSearchStartTime = new DateTimePicker(); dataGridView1 = new DataGridView(); label22 = new Label(); + txtSolidBeveBatch = new TextBox(); + label33 = new Label(); statusStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit(); splitContainer1.Panel1.SuspendLayout(); @@ -457,10 +459,9 @@ namespace FATrace.App panel3.Controls.Add(txtRtWeight); panel3.Controls.Add(label8); panel3.Controls.Add(label10); - panel3.Dock = DockStyle.Top; - panel3.Location = new Point(3, 377); + panel3.Location = new Point(3, 415); panel3.Name = "panel3"; - panel3.Size = new Size(878, 176); + panel3.Size = new Size(878, 140); panel3.TabIndex = 3; // // btnReprint @@ -490,7 +491,7 @@ namespace FATrace.App // btnWeightPrint.Font = new Font("Microsoft YaHei UI", 20F, FontStyle.Bold); btnWeightPrint.ForeColor = SystemColors.ControlDarkDark; - btnWeightPrint.Location = new Point(670, 95); + btnWeightPrint.Location = new Point(670, 63); btnWeightPrint.Name = "btnWeightPrint"; btnWeightPrint.Size = new Size(190, 71); btnWeightPrint.TabIndex = 9; @@ -502,7 +503,7 @@ namespace FATrace.App // txtCode.Font = new Font("Microsoft YaHei UI", 15F, FontStyle.Regular, GraphicsUnit.Point, 134); txtCode.ForeColor = Color.Blue; - txtCode.Location = new Point(129, 127); + txtCode.Location = new Point(129, 96); txtCode.Name = "txtCode"; txtCode.ReadOnly = true; txtCode.Size = new Size(410, 33); @@ -513,7 +514,7 @@ namespace FATrace.App label13.AutoSize = true; label13.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134); label13.ForeColor = SystemColors.WindowFrame; - label13.Location = new Point(30, 130); + label13.Location = new Point(30, 99); label13.Name = "label13"; label13.Size = new Size(107, 26); label13.TabIndex = 15; @@ -563,6 +564,8 @@ namespace FATrace.App // panel2 // panel2.BorderStyle = BorderStyle.FixedSingle; + panel2.Controls.Add(txtSolidBeveBatch); + panel2.Controls.Add(label33); panel2.Controls.Add(pictureBox3); panel2.Controls.Add(lblRawUseStateTip); panel2.Controls.Add(btnClearRaw); @@ -582,7 +585,7 @@ namespace FATrace.App panel2.Dock = DockStyle.Top; panel2.Location = new Point(3, 221); panel2.Name = "panel2"; - panel2.Size = new Size(878, 156); + panel2.Size = new Size(878, 192); panel2.TabIndex = 2; // // pictureBox3 @@ -601,7 +604,7 @@ namespace FATrace.App lblRawUseStateTip.BackColor = Color.LightSalmon; lblRawUseStateTip.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134); lblRawUseStateTip.ForeColor = SystemColors.ButtonHighlight; - lblRawUseStateTip.Location = new Point(168, 106); + lblRawUseStateTip.Location = new Point(168, 150); lblRawUseStateTip.Name = "lblRawUseStateTip"; lblRawUseStateTip.Size = new Size(247, 34); lblRawUseStateTip.TabIndex = 11; @@ -613,7 +616,7 @@ namespace FATrace.App // btnClearRaw.Font = new Font("Microsoft YaHei UI", 15.75F, FontStyle.Bold, GraphicsUnit.Point, 134); btnClearRaw.ForeColor = SystemColors.ControlDarkDark; - btnClearRaw.Location = new Point(581, 93); + btnClearRaw.Location = new Point(581, 137); btnClearRaw.Name = "btnClearRaw"; btnClearRaw.Size = new Size(154, 47); btnClearRaw.TabIndex = 10; @@ -626,7 +629,7 @@ namespace FATrace.App lblRawUseState.BackColor = Color.Tomato; lblRawUseState.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134); lblRawUseState.ForeColor = SystemColors.ButtonHighlight; - lblRawUseState.Location = new Point(24, 97); + lblRawUseState.Location = new Point(24, 141); lblRawUseState.Name = "lblRawUseState"; lblRawUseState.Size = new Size(129, 43); lblRawUseState.TabIndex = 9; @@ -649,7 +652,7 @@ namespace FATrace.App // btnTrueProInput.Font = new Font("Microsoft YaHei UI", 15.75F, FontStyle.Bold, GraphicsUnit.Point, 134); btnTrueProInput.ForeColor = SystemColors.ControlDarkDark; - btnTrueProInput.Location = new Point(741, 93); + btnTrueProInput.Location = new Point(741, 137); btnTrueProInput.Name = "btnTrueProInput"; btnTrueProInput.Size = new Size(119, 47); btnTrueProInput.TabIndex = 8; @@ -825,7 +828,7 @@ namespace FATrace.App btnRawName1.Name = "btnRawName1"; btnRawName1.Size = new Size(266, 48); btnRawName1.TabIndex = 1; - btnRawName1.Text = "1121000265 瑞士乳杆菌GCL1815"; + btnRawName1.Text = "1121000265 瑞士乳杆菌(固体饮料)"; btnRawName1.UseVisualStyleBackColor = true; btnRawName1.Click += btnRawName1_Click; // @@ -1097,6 +1100,25 @@ namespace FATrace.App label22.Text = "历史数据"; label22.TextAlign = ContentAlignment.MiddleCenter; // + // txtSolidBeveBatch + // + txtSolidBeveBatch.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Regular, GraphicsUnit.Point, 134); + txtSolidBeveBatch.Location = new Point(314, 102); + txtSolidBeveBatch.Name = "txtSolidBeveBatch"; + txtSolidBeveBatch.Size = new Size(184, 32); + txtSolidBeveBatch.TabIndex = 16; + // + // label33 + // + label33.AutoSize = true; + label33.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134); + label33.ForeColor = SystemColors.WindowFrame; + label33.Location = new Point(180, 105); + label33.Name = "label33"; + label33.Size = new Size(145, 26); + label33.TabIndex = 15; + label33.Text = "固体饮料批次:"; + // // frmMain // AutoScaleDimensions = new SizeF(7F, 17F); @@ -1232,5 +1254,7 @@ namespace FATrace.App private PictureBox pictureBox5; private Label label31; private Button btnConfigSave; + private TextBox txtSolidBeveBatch; + private Label label33; } } \ No newline at end of file diff --git a/FATrace.App/frmMain.cs b/FATrace.App/frmMain.cs index 619626e..3e00724 100644 --- a/FATrace.App/frmMain.cs +++ b/FATrace.App/frmMain.cs @@ -255,7 +255,7 @@ namespace FATrace.App ListRawCtrInfo = new List() { new RawCtrInfo(){ - RawName="瑞士乳杆菌GCL1815", + RawName="瑞士乳杆菌(固体饮料)", RawCode="1121000265", BtnControlName="btnRawName1", RawSource=RawSource.Japan @@ -463,6 +463,7 @@ namespace FATrace.App txtWeight.Text = CurSelectedRawProInput.Weight.ToString(); txtBatch.Text = CurSelectedRawProInput.Batch!; + txtSolidBeveBatch.Text = CurSelectedRawProInput.SolidBeveBatch ?? ""; txtShelfLife.Text = CurSelectedRawProInput.ShelfLife.ToString(); txtRemainWeight.Text = CurSelectedRawProInput.RemainWeight.ToString(); @@ -572,6 +573,7 @@ namespace FATrace.App // 2) 读取并校验输入框 var weightText = (txtWeight.Text ?? string.Empty).Trim(); var batchText = (txtBatch.Text ?? string.Empty).Trim(); + var solidBeveBatchText = (txtSolidBeveBatch.Text ?? string.Empty).Trim(); var shelfLifeText = (txtShelfLife.Text ?? string.Empty).Trim(); if (string.IsNullOrWhiteSpace(weightText) || @@ -596,6 +598,19 @@ namespace FATrace.App return; } + if (string.IsNullOrWhiteSpace(solidBeveBatchText)) + { + MessageBox.Show("请输入固体饮料批次。", "校验失败", MessageBoxButtons.OK, MessageBoxIcon.Warning); + txtSolidBeveBatch.Focus(); + return; + } + if (solidBeveBatchText.Length > 20) + { + MessageBox.Show("固体饮料批次长度不能超过20个字符。", "校验失败", MessageBoxButtons.OK, MessageBoxIcon.Warning); + txtSolidBeveBatch.Focus(); + return; + } + if (string.IsNullOrWhiteSpace(shelfLifeText) || !int.TryParse(shelfLifeText.Replace(',', '.').Replace('。', '.'), out var shelfLife) || shelfLife <= 0) { @@ -612,6 +627,7 @@ namespace FATrace.App RawCode = CurSelectedRawProInput.RawCode, Weight = Math.Round(weight, 2), // 保留3位小数,避免浮点抖动 Batch = batchText, + SolidBeveBatch = solidBeveBatchText, ShelfLife = shelfLife, RawSource = CurSelectedRawProInput.RawSource, RemainWeight = Math.Round(weight, 2), @@ -687,7 +703,7 @@ namespace FATrace.App MessageBox.Show("请先选择要称重的产品", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } - if (string.IsNullOrEmpty(CurSelectedRawProInput.RawName) || string.IsNullOrEmpty(CurSelectedRawProInput.Batch) || string.IsNullOrEmpty(CurSelectedRawProInput.RawCode)) + if (string.IsNullOrEmpty(CurSelectedRawProInput.RawName) || string.IsNullOrEmpty(CurSelectedRawProInput.Batch) || string.IsNullOrEmpty(CurSelectedRawProInput.SolidBeveBatch) || string.IsNullOrEmpty(CurSelectedRawProInput.RawCode)) { MessageBox.Show("选择的产品信息无数据,请信息输入后再操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; @@ -736,15 +752,21 @@ namespace FATrace.App txtRemainWeight.Text = NewRemainWeight.ToString(); //二维码 - var Code = GenCode(CurSelectedRawProInput.RawCode!, CurWeight, CurSelectedRawProInput.Batch!, CurSelectedRawProInput.ShelfLife, CurSelectedRawProInput.RawSource, CurDayCount.Count); + var solidBeveBatchForCode = (txtSolidBeveBatch.Text ?? string.Empty).Trim(); + if (string.IsNullOrWhiteSpace(solidBeveBatchForCode)) + { + solidBeveBatchForCode = CurSelectedRawProInput.SolidBeveBatch ?? string.Empty; + } + var Code = GenCode(CurSelectedRawProInput.RawCode!, CurWeight, CurSelectedRawProInput.Batch!, solidBeveBatchForCode, CurSelectedRawProInput.ShelfLife, CurSelectedRawProInput.RawSource, CurDayCount.Count); // 执行打印 try { UpdateStatusLabel(tslPrintState, "正在打印...", Color.Goldenrod, Color.White); - CurZebraPrint.PrintWeight(Code, CurSelectedRawProInput.RawName!, + CurZebraPrint.PrintWeight(Code, GetSimpleCode(Code), CurSelectedRawProInput.RawName!, CurWeight, CurSelectedRawProInput.Batch!, + solidBeveBatchForCode, CurSelectedRawProInput.ShelfLife ); SetPrinterStatusOk("打印成功"); @@ -765,6 +787,7 @@ namespace FATrace.App var Result = FSqlContext.FDb.Insert(new RawProUse() { Batch = CurSelectedRawProInput.Batch, + SolidBeveBatch = solidBeveBatchForCode, InBagCode = Code, BoxCode = Code + ",A", OpUser = CurrentOpUserNo, @@ -833,6 +856,34 @@ namespace FATrace.App } } + /// + /// 获取简单的条码 + /// 只要原料编码,批次,序号 + /// + /// + /// + private string GetSimpleCode(string code) + { + if (string.IsNullOrWhiteSpace(code)) + return string.Empty; + + var normalized = code.Trim() + .Replace(',', ',') + .Replace(';', ',') + .Replace(';', ','); + + var parts = normalized.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + if (parts.Length != 7) + return string.Empty; + + // 原料编码,批次,序号(最后一段为 DayCount) + var rawCode = parts[0].Trim(); + var batch = parts[1].Trim(); + var seq = parts[6].Trim(); + return $"{rawCode},{batch},{seq}"; + } + + /// /// 格式化重量显示,自动适配整数部分位数(2-4位),小数部分固定2位 /// @@ -900,6 +951,7 @@ namespace FATrace.App { txtWeight.Text = ""; txtBatch.Text = ""; + txtSolidBeveBatch.Text = ""; txtShelfLife.Text = ""; txtRemainWeight.Text = ""; } @@ -924,7 +976,7 @@ namespace FATrace.App /// 生成条码信息 /// /// - public string GenCode(string RawCode, double Weight, string Batch, int ShelfLife, RawSource Source, int DayCount) + public string GenCode(string RawCode, double Weight, string Batch, string SolidBeveBatch, int ShelfLife, RawSource Source, int DayCount) { //二维码数据 var Code = new StringBuilder(); @@ -932,6 +984,8 @@ namespace FATrace.App Code.Append(','); Code.Append(Batch); Code.Append(','); + Code.Append(SolidBeveBatch); + Code.Append(','); Code.Append(FormatWeight(Weight).ToString().Replace(".", "")); Code.Append(','); Code.Append(ShelfLife.ToString()); @@ -1351,9 +1405,10 @@ namespace FATrace.App try { UpdateStatusLabel(tslPrintState, "正在打印...", Color.Goldenrod, Color.White); - CurZebraPrint.PrintWeight(LastData.InBagCode!, CurSelectedRawProInput.RawName!, + CurZebraPrint.PrintWeight(LastData.InBagCode!, GetSimpleCode(LastData.InBagCode!), CurSelectedRawProInput.RawName!, CurWeight, CurSelectedRawProInput.Batch!, + LastData.SolidBeveBatch ?? "", CurSelectedRawProInput.ShelfLife ); SetPrinterStatusOk("打印成功"); diff --git a/FATrace.Com/NVRCom.cs b/FATrace.Com/NVRCom.cs index 825da5c..0e3f3be 100644 --- a/FATrace.Com/NVRCom.cs +++ b/FATrace.Com/NVRCom.cs @@ -13,6 +13,31 @@ namespace FATrace.Com /// public class NVRCom { + private static string[] SplitCodeParts(string code) + { + if (string.IsNullOrWhiteSpace(code)) return Array.Empty(); + + var normalized = code.Trim() + .Replace(',', ',') + .Replace(';', ',') + .Replace(';', ','); + + // 优先使用逗号分隔,避免 SolidBeveBatch 中包含空格导致被错误切分 + if (normalized.Contains(',')) + { + return normalized + .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) + .Select(p => p.Trim()) + .ToArray(); + } + + // 无逗号时回退到按空白分隔 + return normalized + .Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries) + .Select(p => p.Trim()) + .ToArray(); + } + /// /// 获取视频名称 /// @@ -65,15 +90,13 @@ namespace FATrace.Com try { - // 标准化分隔符并切分:支持 英文逗号/中文逗号/分号/空格 - var normalized = Code.Trim() - .Replace(',', ',') - .Replace(';', ',') - .Replace(';', ','); - var parts = normalized - .Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries) - .Select(p => p.Trim()) - .ToArray(); + var parts = SplitCodeParts(Code); + + // 新二维码固定 7 段:RawCode,Batch,SolidBeveBatch,Weight,ShelfLife,Region,DayCount + if (parts.Length != 7) + { + return (string.Empty, string.Empty, string.Empty); + } string rawCode = parts.Length > 0 ? parts[0] : string.Empty; @@ -88,9 +111,10 @@ namespace FATrace.Com // 重量:3/4 位数字,最后一位为小数位(例:802 => 80.2g)。 string weight = string.Empty; - if (parts.Length > 2) + var weightIndex = 3; + if (parts.Length > 3) { - var digits = new string(parts[2].Where(char.IsDigit).ToArray()); + var digits = new string(parts[weightIndex].Where(char.IsDigit).ToArray()); if (digits.Length >= 2) { // 在最后一位前插入小数点,如 802 => 80.2,1234 => 123.4 @@ -118,14 +142,13 @@ namespace FATrace.Com try { - var normalized = code.Trim() - .Replace(',', ',') - .Replace(';', ',') - .Replace(';', ','); - var parts = normalized - .Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries) - .Select(p => p.Trim()) - .ToArray(); + var parts = SplitCodeParts(code); + + // 新二维码固定 7 段:RawCode,Batch,SolidBeveBatch,Weight,ShelfLife,Region,DayCount + if (parts.Length != 7) + { + return result; + } result.RawCode = parts.Length > 0 ? parts[0] : string.Empty; @@ -135,9 +158,13 @@ namespace FATrace.Com result.Batch = digits.Length >= 8 ? digits.Substring(0, 8) : digits; } - if (parts.Length > 2) + // 新二维码(7段)第3段为固体饮料批次 + result.SolidBeveBatch = parts[2]; + + var weightIndex = 3; + if (parts.Length > 3) { - var digits = new string(parts[2].Where(char.IsDigit).ToArray()); + var digits = new string(parts[weightIndex].Where(char.IsDigit).ToArray()); string weightStr = string.Empty; if (digits.Length >= 2) { @@ -154,22 +181,25 @@ namespace FATrace.Com } } - if (parts.Length > 3) + var shelfLifeIndex = 4; + if (parts.Length > 4) { - var digits = new string(parts[3].Where(char.IsDigit).ToArray()); + var digits = new string(parts[shelfLifeIndex].Where(char.IsDigit).ToArray()); if (int.TryParse(digits, out var m)) result.ShelfLifeMonths = m; } - if (parts.Length > 4) + var regionIndex = 5; + if (parts.Length > 5) { - var digits = new string(parts[4].Where(char.IsDigit).ToArray()); + var digits = new string(parts[regionIndex].Where(char.IsDigit).ToArray()); result.RegionCode = digits; result.RegionName = digits == "01" ? "国内" : (digits == "02" ? "日本" : "未知"); } - if (parts.Length > 5) + var countIndex = 6; + if (parts.Length > 6) { - var digits = new string(parts[5].Where(char.IsDigit).ToArray()); + var digits = new string(parts[countIndex].Where(char.IsDigit).ToArray()); if (int.TryParse(digits, out var c)) result.Count = c; } } diff --git a/FATrace.Com/ParsedCodeInfo.cs b/FATrace.Com/ParsedCodeInfo.cs index 04c683b..c8919fb 100644 --- a/FATrace.Com/ParsedCodeInfo.cs +++ b/FATrace.Com/ParsedCodeInfo.cs @@ -17,6 +17,7 @@ namespace FATrace.Com public string RawCode { get; set; } = string.Empty; public string RawName { get; set; } = string.Empty; public string Batch { get; set; } = string.Empty; + public string SolidBeveBatch { get; set; } = string.Empty; public decimal Weight { get; set; } public int ShelfLifeMonths { get; set; } public string RegionCode { get; set; } = string.Empty; diff --git a/FATrace.Model/QRModel.cs b/FATrace.Model/QRModel.cs index f9f6095..59ef080 100644 --- a/FATrace.Model/QRModel.cs +++ b/FATrace.Model/QRModel.cs @@ -31,7 +31,12 @@ namespace FATrace.Model /// /// 批号 /// - public string Batch { get; set; } + public string Batch { get; set; } = string.Empty; + + /// + /// 固体饮料批次 + /// + public string SolidBeveBatch { get; set; } = string.Empty; /// /// 重量(第三段解析后的实际数值,比如 802 -> 80.2) @@ -69,21 +74,28 @@ namespace FATrace.Model } var parts = text.Split(','); - if (parts.Length != 6) + if (parts.Length != 7) { - throw new ArgumentException($"二维码格式不正确,预期 6 段,实际为 {parts.Length} 段。内容:{text}", nameof(text)); + throw new ArgumentException($"二维码格式不正确,预期 7 段,实际为 {parts.Length} 段。内容:{text}", nameof(text)); } + var weightIndex = 3; + var shelfLifeIndex = 4; + var rawSourceIndex = 5; + var seqIndex = 6; + var model = new QRModel { RawText = text.Trim(), RawCode = parts[0].Trim(), Batch = parts[1].Trim(), - RawSource = parts[4].Trim() + RawSource = parts[rawSourceIndex].Trim() }; + model.SolidBeveBatch = parts[2].Trim(); + // 重量:3/4 位数字,末位为小数位,例如 802 -> 80.2 - var weightCode = parts[2].Trim(); + var weightCode = parts[weightIndex].Trim(); if (!int.TryParse(weightCode, out var weightInt)) { throw new ArgumentException($"重量段不是有效数字:{weightCode}", nameof(text)); @@ -92,7 +104,7 @@ namespace FATrace.Model model.Weight = weightInt / 10m; // 保质期(月) - var shelfText = parts[3].Trim(); + var shelfText = parts[shelfLifeIndex].Trim(); if (!int.TryParse(shelfText, out var shelfMonths) || shelfMonths < 0) { throw new ArgumentException($"保质期(月)不是有效数字:{shelfText}", nameof(text)); @@ -100,7 +112,7 @@ namespace FATrace.Model model.ShelfLife = shelfMonths; // 当日序号 - var seqText = parts[5].Trim(); + var seqText = parts[seqIndex].Trim(); if (!int.TryParse(seqText, out var seq) || seq < 0) { throw new ArgumentException($"当日生产序号不是有效数字:{seqText}", nameof(text)); diff --git a/FATrace.Model/RawProInput.cs b/FATrace.Model/RawProInput.cs index d3a604a..0ca95c3 100644 --- a/FATrace.Model/RawProInput.cs +++ b/FATrace.Model/RawProInput.cs @@ -39,6 +39,12 @@ namespace FATrace.Model [Column(Name = "Batch", IsNullable = false, StringLength = 50)] public string? Batch { get; set; } + /// + /// 固体饮料批次 + /// + [Column(Name = "SolidBeveBatch", StringLength = 50)] + public string? SolidBeveBatch { get; set; } + /// /// 保质期 年 /// diff --git a/FATrace.Model/RawProUse.cs b/FATrace.Model/RawProUse.cs index 8d390c9..f3b536e 100644 --- a/FATrace.Model/RawProUse.cs +++ b/FATrace.Model/RawProUse.cs @@ -50,6 +50,12 @@ namespace FATrace.Model [Column(Name = "Batch", IsNullable = false, StringLength = 50)] public string? Batch { get; set; } + /// + /// 固体饮料批次 + /// + [Column(Name = "SolidBeveBatch", StringLength = 50)] + public string? SolidBeveBatch { get; set; } + /// /// 配料日期 当天日期 /// 年,月,日 diff --git a/FATrace.WPLApp/CsvModel/RawProUserCsvDtoMap.cs b/FATrace.WPLApp/CsvModel/RawProUserCsvDtoMap.cs index b25bff9..cf1799b 100644 --- a/FATrace.WPLApp/CsvModel/RawProUserCsvDtoMap.cs +++ b/FATrace.WPLApp/CsvModel/RawProUserCsvDtoMap.cs @@ -30,15 +30,16 @@ namespace FATrace.WPLApp.CsvModel Map(x => x.InBagCode).Index(2).Name("内袋二维码"); Map(x => x.BoxCode).Index(3).Name("外箱二维码"); Map(x => x.Batch).Index(4).Name("批号"); - Map(x => x.ShelfLife).Index(5).Name("保质期"); - Map(x => x.Weight).Index(6).Name("称重重量(g)"); - Map(x => x.DeliveryDate).Index(7).Name("配料日期"); - Map(x => x.RemainWeight).Index(8).Name("剩余重量(Kg)"); - Map(x => x.StockWeight).Index(9).Name("入库总重量(Kg)"); - Map(x => x.WeightTime).Index(10).Name("称重时间").TypeConverterOption.Format("yyyy-MM-dd HH:mm:ss"); - Map(x => x.OpUser).Index(11).Name("操作者"); - Map(x => x.CheckUser).Index(12).Name("确认者"); - Map(x => x.OutTime).Index(13).Name("外箱扫码时间").TypeConverterOption.Format("yyyy-MM-dd HH:mm:ss"); + Map(x => x.SolidBeveBatch).Index(5).Name("固体饮料批次"); + Map(x => x.ShelfLife).Index(6).Name("保质期"); + Map(x => x.Weight).Index(7).Name("称重重量(g)"); + Map(x => x.DeliveryDate).Index(8).Name("配料日期"); + Map(x => x.RemainWeight).Index(9).Name("剩余重量(Kg)"); + Map(x => x.StockWeight).Index(10).Name("入库总重量(Kg)"); + Map(x => x.WeightTime).Index(11).Name("称重时间").TypeConverterOption.Format("yyyy-MM-dd HH:mm:ss"); + Map(x => x.OpUser).Index(12).Name("操作者"); + Map(x => x.CheckUser).Index(13).Name("确认者"); + Map(x => x.OutTime).Index(14).Name("外箱扫码时间").TypeConverterOption.Format("yyyy-MM-dd HH:mm:ss"); } } diff --git a/FATrace.WPLApp/ModelDto/RawProInputDto.cs b/FATrace.WPLApp/ModelDto/RawProInputDto.cs index 6684a64..fd00e75 100644 --- a/FATrace.WPLApp/ModelDto/RawProInputDto.cs +++ b/FATrace.WPLApp/ModelDto/RawProInputDto.cs @@ -12,6 +12,7 @@ namespace FATrace.WPLApp.ModelDto public string? RawName { get; set; } public double Weight { get; set; } public string? Batch { get; set; } + public string? SolidBeveBatch { get; set; } public int ShelfLife { get; set; } public string RawSource { get; set; } = string.Empty; // 展示为文本 public double RemainWeight { get; set; } diff --git a/FATrace.WPLApp/ModelDto/RawProUseDto.cs b/FATrace.WPLApp/ModelDto/RawProUseDto.cs index b3eba06..18d0678 100644 --- a/FATrace.WPLApp/ModelDto/RawProUseDto.cs +++ b/FATrace.WPLApp/ModelDto/RawProUseDto.cs @@ -39,6 +39,11 @@ namespace FATrace.WPLApp.ModelDto /// public string? Batch { get; set; } + /// + /// 固体饮料批次 + /// + public string? SolidBeveBatch { get; set; } + /// /// 配料日期 /// diff --git a/FATrace.WPLApp/ModelDto/RawProUserCsvDto.cs b/FATrace.WPLApp/ModelDto/RawProUserCsvDto.cs index 627ab4f..78d4df9 100644 --- a/FATrace.WPLApp/ModelDto/RawProUserCsvDto.cs +++ b/FATrace.WPLApp/ModelDto/RawProUserCsvDto.cs @@ -36,6 +36,11 @@ namespace FATrace.WPLApp.ModelDto /// public string? Batch { get; set; } + /// + /// 固体饮料批次 + /// + public string? SolidBeveBatch { get; set; } + /// /// 保质期 年 /// diff --git a/FATrace.WPLApp/ViewModels/RawProInputViewModel.cs b/FATrace.WPLApp/ViewModels/RawProInputViewModel.cs index 2269d46..5cac496 100644 --- a/FATrace.WPLApp/ViewModels/RawProInputViewModel.cs +++ b/FATrace.WPLApp/ViewModels/RawProInputViewModel.cs @@ -68,6 +68,9 @@ namespace FATrace.WPLApp.ViewModels public string? Batch { get => _batch; set { _batch = value; RaisePropertyChanged(); } } private string? _batch; + public string? SolidBeveBatch { get => _solidBeveBatch; set { _solidBeveBatch = value; RaisePropertyChanged(); } } + private string? _solidBeveBatch; + /// /// 原料来源(可空) /// @@ -144,7 +147,7 @@ namespace FATrace.WPLApp.ViewModels /// private void ClearFilters() { - RawCode = RawName = Batch = string.Empty; + RawCode = RawName = Batch = SolidBeveBatch = string.Empty; SelectedRawSource = null; SelectedRawState = null; StartTime = DateTime.Today; @@ -188,6 +191,7 @@ namespace FATrace.WPLApp.ViewModels if (!string.IsNullOrWhiteSpace(RawCode)) q = q.Where(a => a.RawCode.Contains(RawCode)); if (!string.IsNullOrWhiteSpace(RawName)) q = q.Where(a => a.RawName.Contains(RawName)); if (!string.IsNullOrWhiteSpace(Batch)) q = q.Where(a => a.Batch.Contains(Batch)); + if (!string.IsNullOrWhiteSpace(SolidBeveBatch)) q = q.Where(a => a.SolidBeveBatch.Contains(SolidBeveBatch)); if (SelectedRawSource.HasValue) q = q.Where(a => a.RawSource == SelectedRawSource.Value); if (SelectedRawState.HasValue) q = q.Where(a => a.RawState == SelectedRawState.Value); @@ -206,6 +210,7 @@ namespace FATrace.WPLApp.ViewModels RawName = a.RawName, Weight = a.Weight, Batch = a.Batch, + SolidBeveBatch = a.SolidBeveBatch, ShelfLife = a.ShelfLife, RawSource = a.RawSource.ToString(), RemainWeight = a.RemainWeight, @@ -224,6 +229,7 @@ namespace FATrace.WPLApp.ViewModels RawName = a.RawName, Weight = a.Weight, Batch = a.Batch, + SolidBeveBatch = a.SolidBeveBatch, ShelfLife = a.ShelfLife, RawSource = a.RawSource.ToString(), RemainWeight = a.RemainWeight, @@ -287,7 +293,7 @@ namespace FATrace.WPLApp.ViewModels var header = sheet.CreateRow(0); string[] headers = new[] { - "Id","原料编号","原料名称","入库重量(kg)","批号","保质期(年)","原料来源","剩余重量(kg)","分拆状态","创建时间" + "Id","原料编号","原料名称","入库重量(kg)","批号","固体饮料批次","保质期(年)","原料来源","剩余重量(kg)","分拆状态","创建时间" }; var headerFont = workbook.CreateFont(); headerFont.IsBold = true; @@ -321,6 +327,7 @@ namespace FATrace.WPLApp.ViewModels row.CreateCell(c++).SetCellValue(it.RawName ?? string.Empty); row.CreateCell(c++).SetCellValue(it.Weight); row.CreateCell(c++).SetCellValue(it.Batch ?? string.Empty); + row.CreateCell(c++).SetCellValue(it.SolidBeveBatch ?? string.Empty); row.CreateCell(c++).SetCellValue(it.ShelfLife); row.CreateCell(c++).SetCellValue(it.RawSource); row.CreateCell(c++).SetCellValue(it.RemainWeight); diff --git a/FATrace.WPLApp/ViewModels/RawProUseViewModel.cs b/FATrace.WPLApp/ViewModels/RawProUseViewModel.cs index c61fde2..fc15fde 100644 --- a/FATrace.WPLApp/ViewModels/RawProUseViewModel.cs +++ b/FATrace.WPLApp/ViewModels/RawProUseViewModel.cs @@ -129,6 +129,12 @@ namespace FATrace.WPLApp.ViewModels /// public string? Batch { get => _batch; set { _batch = value; RaisePropertyChanged(); } } + private string? _solidBeveBatch; + /// + /// 固体饮料批次模糊匹配 + /// + public string? SolidBeveBatch { get => _solidBeveBatch; set { _solidBeveBatch = value; RaisePropertyChanged(); } } + private string? _opUser; /// /// 操作者模糊匹配 @@ -228,7 +234,7 @@ namespace FATrace.WPLApp.ViewModels /// private void ClearFilters() { - RawCode = RawName = InBagCode = BoxCode = Batch = OpUser = CheckUser = string.Empty; + RawCode = RawName = InBagCode = BoxCode = Batch = SolidBeveBatch = OpUser = CheckUser = string.Empty; StartTime = DateTime.Today; EndTime = DateTime.Today.AddDays(1).AddSeconds(-1); } @@ -277,6 +283,8 @@ namespace FATrace.WPLApp.ViewModels q = q.Where(a => a.BoxCode.Contains(BoxCode)); if (!string.IsNullOrWhiteSpace(Batch)) q = q.Where(a => a.Batch.Contains(Batch)); + if (!string.IsNullOrWhiteSpace(SolidBeveBatch)) + q = q.Where(a => a.SolidBeveBatch.Contains(SolidBeveBatch)); if (!string.IsNullOrWhiteSpace(OpUser)) q = q.Where(a => a.OpUser.Contains(OpUser)); if (!string.IsNullOrWhiteSpace(CheckUser)) @@ -298,6 +306,7 @@ namespace FATrace.WPLApp.ViewModels InBagCode = a.InBagCode, BoxCode = a.BoxCode, Batch = a.Batch, + SolidBeveBatch = a.SolidBeveBatch, ShelfLife = a.ShelfLife, Weight = a.Weight, RemainWeight = a.RemainWeight, @@ -322,6 +331,7 @@ namespace FATrace.WPLApp.ViewModels InBagCode = a.InBagCode, BoxCode = a.BoxCode, Batch = a.Batch, + SolidBeveBatch = a.SolidBeveBatch, ShelfLife = a.ShelfLife, Weight = a.Weight, RemainWeight = a.RemainWeight, @@ -447,7 +457,7 @@ namespace FATrace.WPLApp.ViewModels var header = sheet.CreateRow(0); string[] headers = new[] { - "Id","原料编号","原料名称","内袋二维码","外箱二维码","批号","保质期(年)", + "Id","原料编号","原料名称","内袋二维码","外箱二维码","批号","固体饮料批次","保质期(年)", "称重重量(g)","剩余重量(g)","入库总重量(g)","称重时间","操作者","确认者","出库时间","创建时间" }; // 表头样式:加粗与更大字号 @@ -484,6 +494,7 @@ namespace FATrace.WPLApp.ViewModels row.CreateCell(c++).SetCellValue(it.InBagCode ?? string.Empty); row.CreateCell(c++).SetCellValue(it.BoxCode ?? string.Empty); row.CreateCell(c++).SetCellValue(it.Batch ?? string.Empty); + row.CreateCell(c++).SetCellValue(it.SolidBeveBatch ?? string.Empty); row.CreateCell(c++).SetCellValue(it.ShelfLife); row.CreateCell(c++).SetCellValue(it.Weight); row.CreateCell(c++).SetCellValue(it.RemainWeight); diff --git a/FATrace.WPLApp/Views/RawProInputView.xaml b/FATrace.WPLApp/Views/RawProInputView.xaml index 2fb3d41..336daff 100644 --- a/FATrace.WPLApp/Views/RawProInputView.xaml +++ b/FATrace.WPLApp/Views/RawProInputView.xaml @@ -75,6 +75,14 @@ + + + + + + @@ -80,12 +81,20 @@ Grid.Column="3" Margin="0,0,10,8" Orientation="Horizontal"> + + + + @@ -236,6 +245,10 @@ Width="120" Binding="{Binding Batch}" Header="批号" /> +