增加固体饮料批号初版

This commit is contained in:
2026-04-29 09:52:08 +08:00
parent 7f7eb32ca3
commit add4308b91
17 changed files with 354 additions and 90 deletions

View File

@@ -1,4 +1,5 @@
using NLog; using NLog;
using FATrace.Model;
namespace FATrace.App namespace FATrace.App
{ {
@@ -42,6 +43,19 @@ namespace FATrace.App
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
// 结构同步App 端当前 UseAutoSyncStructure(false),需要显式同步新增列
try
{
FSqlContext.FDb.CodeFirst.SyncStructure<RawProInput>();
FSqlContext.FDb.CodeFirst.SyncStructure<RawProUse>();
}
catch (Exception ex)
{
logger.Error(ex, "数据库结构同步失败");
MessageBox.Show($"数据库结构同步失败:{ex.Message}");
}
Application.Run(new frmMain()); Application.Run(new frmMain());
} }

View File

@@ -86,10 +86,63 @@ namespace FATrace.App
} }
} }
///// <summary>
///// 打印称重信息
///// </summary>
//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());
//}
/// <summary> /// <summary>
/// 打印称重信息 /// 打印称重信息
/// </summary> /// </summary>
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(); //var Code = new StringBuilder();
@@ -103,36 +156,44 @@ namespace FATrace.App
//Code.Append(','); //Code.Append(',');
//Code.Append(DayCount.ToString()); //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(); var PrintZpl = new StringBuilder();
PrintZpl.AppendLine("~DGRawNameCN.GRF,1647,27,k0Y01K08K08M08R01g038J0EK0FL01CP0601CR0EL07CJ0FK0FL01FO01F01ER0OFJ0EK0EL03CO0HF83CR07R0EK0EL038N0HF803CR07I03N0E1J0EL078I0CI0HFCH038R07I07CK040E186H0EL07I01EH0101CH078R07I07L060E3E380EL0LF8I01CH07S07I06L070E381E0EL0EI01EJ01CH07I02O07I0CH02I038E3H0F0EK01CI03CJ01CH0EI07O070608H07I038E7H0F0EK038I078J01CH0KF8N0707KF8H03CE6H070EK07J078J01CH0EI0F8N0707J07I018E4H070EK07J0FK01CE1CI0EO0707J07I018ECH020EK0FCH01EK01DE18181CO0707J07K0E8J0EJ01CFH03CI03JFB81E18O0707J07K0E18I0EJ03078078K03C0301C3P0707J07K0E3CI0EJ0603C0FL03C0601C2P0707KFH01KFI0EJ0C03C1EL03C0601CQ0707J07J01EH06H0EI01801C3CL07C0C01CQ0707J07J03EH0380EI02H01878L07F0801CQ0707J07J03EH03C0EN0FM07D8061CQ0707J07J03FH01E0EM01EM0FDE079D8P0707J07J07FCH0F0EM07CM0FCF0F1HCP0607J07J07EFH0E0EM0FM01DC70F1C6P0607KFJ07E78060EL0DEI03I01DC70E1C7P060701C07J0HE3C060E3K0F8I038H039C31E1C38O0E0601C06J0CE1CI0E38I01LFCH039C31C1C38O0EI01CK01CE1CI0E7CI03EJ038H071C01C1C1CO0EI01CK018E08I0FCJ0FEJ038H061C0381C1EO0EH0C1CK030EI03FEJ03CEJ038H0E1C0301C0FO0EH0E1HCJ070EH07F0EJ0F0EJ038H0C1C0701C0FO0C01F1C78I060E3FCH0EI03C0EJ0380181C0601C078N0C03C1C1EI0C0E0CI0EI0EH0EJ0380301C0C01C078M01C0781C0F80180EK0EH03I0EJ0380201C1801C038M01C0F01C07E01H0EK0EL0EJ038I01C1801C038M0181C01C03F02H0EK0EL0EJ038I01C3H01C03N0383801CH0FJ0EK0EL0EJ038I01C6H01CP0307H01CH0FJ0EK0EL0EJ038I01CI01CP060C063CH07J0EK0EL0EJ038I01CH0E1CP061803FCH03J0EK0EL0LF8I01CH03FCP0C2I0F8M0EK0EL0EJ038I01CH01F8P08J078M0EK0EL0EJ03J01CI0FP01K02N0CK0EL0CO01J06g0K08K08z0z0h0"); PrintZpl.AppendLine("~DGBatchCN.GRF,315,9,g0718M018L079E38H01IFCL070C3CH01801CL070C38H01801CL030C38H01801CL036C38H01801CK07HFC39C01801CL030DB9E01IFCL030HFB8018018L030C3FL018K037C3E03KFCK03HC38I07O0F0C38I07N07F0C38I07N03B0C38I0EH0CL030C38H01IFEL030C38I0C01CL030C78CJ01CL030CF8CJ01CL030FB8CJ01CL031F38CJ038K03F1E39EI0C38L0F0C3FCI0HF8L0EN03FV01Cn0M0");
PrintZpl.AppendLine("~DGWeightCN.GRF,407,11,h0P06L01S07FI0JF8O03HF8J0CH01R01K0JFR01H0CH0CH01P0KFEH0CH01R01K0JFR0102I0CH01P01JFM018N01810201LFC06L018102P0FL018102I0JF8H06L01IFEI0C0818O018102I0C0818O018103I0C0818O01JFI0JF8O018103I0C0818Q01K0JF8Q01018H0C081P07JFCJ08S01M080CH06N01J03JFEH0FN01H07J08J06K03LF8I08018U0LFCq0L0"); PrintZpl.AppendLine("~DGShelfLifeCN.GRF,420,12,g0L01CO0EH0618M01EH02K0HFH079HC18J01DIF806HF8I071CHFCJ039C07H0783J071HE1CJ039C07H0603CH03IFE1CJ031C07H060383H071CE1CJ071C07H07JF8071CE1CJ061C07H06038I071CE1CJ0F1C07H06038I07FCHFCJ0F1IFH060384H071CE1CI01F1CE7H067IFH071CE1CI03FH0EI0H6H0EH07FCE1CI037H0E0C0H630EH071CE1CI067JFE0E63CEH071CE1CJ0703FI0E638EH071EHFCJ0703F8H0E638E03IFE1CJ0707F8H0E638EH03H0E1CJ0707FCH0C630EH03B0E1CJ070IE01C670EH07HDC1CJ071CE701C67CI071DC1CJ0718E78180E78H0E0F81CJ0730E3E381C1F01C0F81CJ0760E1C30380F818071FCJ07C0EH060EH0783H0E078J06H0CI078H030601C03p0Y0");
PrintZpl.AppendLine("~DGBatchCN.GRF,407,11,g0J01g0G01CO01P018608I07IF8O01870EI06H03P01860CI06H03P01B60CI06H03O03HFE0CI06H03P01860CI06H03P01860C3H07IFP018H6C7806H03P0187FC6O06L01BE0HCL03H0FL01E60FH0LF806L03860EJ0CQ01F860CJ0CQ039860CI018018N0H1860CI03IFCO01860CI01H018O01860CL038O01860C1K03P01861C1K03P018H6C1K03I06L0186HC1K03I0FL01878C1I0106I06K01F870E38I0FEP070207FJ03CP02O03p0M0");
PrintZpl.AppendLine("~DGShelfLifeCN.GRF,814,22,h0M04O018g0R07I08K0FEH0C1M08K0806R0E7HFC0107F8I0E18H08H01801IFC03R0C601801F8K0C18HFCH03H018018018Q0C601801807J0C18C0CH06H018018H08P018601801806I07IFC0CH04H018018H0CP01860180180606H0C18C0CH0CH018018H06P030601801KFH0C18C0CH08H018018H06P038601801806J0C18C0C018H01IF8H03P0707HF801806J0HF8HFC018H018018H03P07063180180608H0C18C0C03I018018H03I06L0DH03I019IFCH0C18C0C03I018018H03I0FL09H03I0198H08H0C18C0C03I018018H03I06K0H1H03030198408H0HF8C0C03I018018H03O0217JF8198708H0C18C0C03I018018H03P01H07I0198608H0C18HFC03I01IF8H03P01H0F4H0H18608H0C1HC0C03I018018H03P01H0F6H031860C07IFC0C018H03H018H03P0101B2H031860CK0C0C018H03H018H03P010I3H0318C0CH0620C0C018H03H018H06P010H3180218C08H073980CH0CH03H018H06P010631C0601F8I0E1D80CH04H06H018H0CI06L010C30E0401878H0C0DH0CH06H06H018H08I0FL0H18307H80701E0180BH0CH03H0CH018018I06L0130302080CH0E02H060F8H0181803F803Q01403H0103I0604H0C038I083I07806Q03H02J0CI02I01H01K04I02z0N0"); 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("^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("^FO30,12^XG");
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(RawNameUnicodeZplStr);
PrintZpl.AppendLine("^FS\r\n^FO8,166^XG"); PrintZpl.AppendLine("^Fs");
PrintZpl.AppendLine("WeightCN");
PrintZpl.AppendLine("^Fs\r\n^FT89,191^A0N,29,48^FH\\^CI28^FD"); PrintZpl.AppendLine("^FO68,128^XG");
PrintZpl.AppendLine(Weight.ToString() + "g");
PrintZpl.AppendLine("^FS^CI27\r\n^FO8,215^XG");
PrintZpl.AppendLine("BatchCN"); PrintZpl.AppendLine("BatchCN");
PrintZpl.AppendLine("^Fs\r\n^FT92,241^A0N,29,41^FH\\^CI28^FD"); PrintZpl.AppendLine("^Fs");
PrintZpl.AppendLine(Batch); PrintZpl.AppendLine("^FO20,180^A0N,30,30^FD");
PrintZpl.AppendLine("^FS^CI27\r\n^FO8,267^XG"); PrintZpl.AppendLine(SolidBeveBatch);
PrintZpl.AppendLine("^FS");
PrintZpl.AppendLine("^FO50,240^XG");
PrintZpl.AppendLine("ShelfLifeCN"); 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("^Fs");
PrintZpl.AppendLine(Code.ToString()); PrintZpl.AppendLine("^FO1,3^GB4,348,4^FS");
PrintZpl.AppendLine("^FS^CI27\r\n^FT175,293^A0N,28,48^FH\\^CI28^FD"); 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(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(); //var dd= PrintZpl.ToString();
this.PrintZpl(PrintZpl.ToString()); this.PrintZpl(PrintZpl.ToString());

View File

@@ -114,6 +114,8 @@ namespace FATrace.App
dtpSearchStartTime = new DateTimePicker(); dtpSearchStartTime = new DateTimePicker();
dataGridView1 = new DataGridView(); dataGridView1 = new DataGridView();
label22 = new Label(); label22 = new Label();
txtSolidBeveBatch = new TextBox();
label33 = new Label();
statusStrip1.SuspendLayout(); statusStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit(); ((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
splitContainer1.Panel1.SuspendLayout(); splitContainer1.Panel1.SuspendLayout();
@@ -457,10 +459,9 @@ namespace FATrace.App
panel3.Controls.Add(txtRtWeight); panel3.Controls.Add(txtRtWeight);
panel3.Controls.Add(label8); panel3.Controls.Add(label8);
panel3.Controls.Add(label10); panel3.Controls.Add(label10);
panel3.Dock = DockStyle.Top; panel3.Location = new Point(3, 415);
panel3.Location = new Point(3, 377);
panel3.Name = "panel3"; panel3.Name = "panel3";
panel3.Size = new Size(878, 176); panel3.Size = new Size(878, 140);
panel3.TabIndex = 3; panel3.TabIndex = 3;
// //
// btnReprint // btnReprint
@@ -490,7 +491,7 @@ namespace FATrace.App
// //
btnWeightPrint.Font = new Font("Microsoft YaHei UI", 20F, FontStyle.Bold); btnWeightPrint.Font = new Font("Microsoft YaHei UI", 20F, FontStyle.Bold);
btnWeightPrint.ForeColor = SystemColors.ControlDarkDark; btnWeightPrint.ForeColor = SystemColors.ControlDarkDark;
btnWeightPrint.Location = new Point(670, 95); btnWeightPrint.Location = new Point(670, 63);
btnWeightPrint.Name = "btnWeightPrint"; btnWeightPrint.Name = "btnWeightPrint";
btnWeightPrint.Size = new Size(190, 71); btnWeightPrint.Size = new Size(190, 71);
btnWeightPrint.TabIndex = 9; btnWeightPrint.TabIndex = 9;
@@ -502,7 +503,7 @@ namespace FATrace.App
// //
txtCode.Font = new Font("Microsoft YaHei UI", 15F, FontStyle.Regular, GraphicsUnit.Point, 134); txtCode.Font = new Font("Microsoft YaHei UI", 15F, FontStyle.Regular, GraphicsUnit.Point, 134);
txtCode.ForeColor = Color.Blue; txtCode.ForeColor = Color.Blue;
txtCode.Location = new Point(129, 127); txtCode.Location = new Point(129, 96);
txtCode.Name = "txtCode"; txtCode.Name = "txtCode";
txtCode.ReadOnly = true; txtCode.ReadOnly = true;
txtCode.Size = new Size(410, 33); txtCode.Size = new Size(410, 33);
@@ -513,7 +514,7 @@ namespace FATrace.App
label13.AutoSize = true; label13.AutoSize = true;
label13.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134); label13.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134);
label13.ForeColor = SystemColors.WindowFrame; label13.ForeColor = SystemColors.WindowFrame;
label13.Location = new Point(30, 130); label13.Location = new Point(30, 99);
label13.Name = "label13"; label13.Name = "label13";
label13.Size = new Size(107, 26); label13.Size = new Size(107, 26);
label13.TabIndex = 15; label13.TabIndex = 15;
@@ -563,6 +564,8 @@ namespace FATrace.App
// panel2 // panel2
// //
panel2.BorderStyle = BorderStyle.FixedSingle; panel2.BorderStyle = BorderStyle.FixedSingle;
panel2.Controls.Add(txtSolidBeveBatch);
panel2.Controls.Add(label33);
panel2.Controls.Add(pictureBox3); panel2.Controls.Add(pictureBox3);
panel2.Controls.Add(lblRawUseStateTip); panel2.Controls.Add(lblRawUseStateTip);
panel2.Controls.Add(btnClearRaw); panel2.Controls.Add(btnClearRaw);
@@ -582,7 +585,7 @@ namespace FATrace.App
panel2.Dock = DockStyle.Top; panel2.Dock = DockStyle.Top;
panel2.Location = new Point(3, 221); panel2.Location = new Point(3, 221);
panel2.Name = "panel2"; panel2.Name = "panel2";
panel2.Size = new Size(878, 156); panel2.Size = new Size(878, 192);
panel2.TabIndex = 2; panel2.TabIndex = 2;
// //
// pictureBox3 // pictureBox3
@@ -601,7 +604,7 @@ namespace FATrace.App
lblRawUseStateTip.BackColor = Color.LightSalmon; lblRawUseStateTip.BackColor = Color.LightSalmon;
lblRawUseStateTip.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134); lblRawUseStateTip.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134);
lblRawUseStateTip.ForeColor = SystemColors.ButtonHighlight; lblRawUseStateTip.ForeColor = SystemColors.ButtonHighlight;
lblRawUseStateTip.Location = new Point(168, 106); lblRawUseStateTip.Location = new Point(168, 150);
lblRawUseStateTip.Name = "lblRawUseStateTip"; lblRawUseStateTip.Name = "lblRawUseStateTip";
lblRawUseStateTip.Size = new Size(247, 34); lblRawUseStateTip.Size = new Size(247, 34);
lblRawUseStateTip.TabIndex = 11; 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.Font = new Font("Microsoft YaHei UI", 15.75F, FontStyle.Bold, GraphicsUnit.Point, 134);
btnClearRaw.ForeColor = SystemColors.ControlDarkDark; btnClearRaw.ForeColor = SystemColors.ControlDarkDark;
btnClearRaw.Location = new Point(581, 93); btnClearRaw.Location = new Point(581, 137);
btnClearRaw.Name = "btnClearRaw"; btnClearRaw.Name = "btnClearRaw";
btnClearRaw.Size = new Size(154, 47); btnClearRaw.Size = new Size(154, 47);
btnClearRaw.TabIndex = 10; btnClearRaw.TabIndex = 10;
@@ -626,7 +629,7 @@ namespace FATrace.App
lblRawUseState.BackColor = Color.Tomato; lblRawUseState.BackColor = Color.Tomato;
lblRawUseState.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134); lblRawUseState.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134);
lblRawUseState.ForeColor = SystemColors.ButtonHighlight; lblRawUseState.ForeColor = SystemColors.ButtonHighlight;
lblRawUseState.Location = new Point(24, 97); lblRawUseState.Location = new Point(24, 141);
lblRawUseState.Name = "lblRawUseState"; lblRawUseState.Name = "lblRawUseState";
lblRawUseState.Size = new Size(129, 43); lblRawUseState.Size = new Size(129, 43);
lblRawUseState.TabIndex = 9; 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.Font = new Font("Microsoft YaHei UI", 15.75F, FontStyle.Bold, GraphicsUnit.Point, 134);
btnTrueProInput.ForeColor = SystemColors.ControlDarkDark; btnTrueProInput.ForeColor = SystemColors.ControlDarkDark;
btnTrueProInput.Location = new Point(741, 93); btnTrueProInput.Location = new Point(741, 137);
btnTrueProInput.Name = "btnTrueProInput"; btnTrueProInput.Name = "btnTrueProInput";
btnTrueProInput.Size = new Size(119, 47); btnTrueProInput.Size = new Size(119, 47);
btnTrueProInput.TabIndex = 8; btnTrueProInput.TabIndex = 8;
@@ -825,7 +828,7 @@ namespace FATrace.App
btnRawName1.Name = "btnRawName1"; btnRawName1.Name = "btnRawName1";
btnRawName1.Size = new Size(266, 48); btnRawName1.Size = new Size(266, 48);
btnRawName1.TabIndex = 1; btnRawName1.TabIndex = 1;
btnRawName1.Text = "1121000265 瑞士乳杆菌GCL1815"; btnRawName1.Text = "1121000265 瑞士乳杆菌(固体饮料)";
btnRawName1.UseVisualStyleBackColor = true; btnRawName1.UseVisualStyleBackColor = true;
btnRawName1.Click += btnRawName1_Click; btnRawName1.Click += btnRawName1_Click;
// //
@@ -1097,6 +1100,25 @@ namespace FATrace.App
label22.Text = "历史数据"; label22.Text = "历史数据";
label22.TextAlign = ContentAlignment.MiddleCenter; 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 // frmMain
// //
AutoScaleDimensions = new SizeF(7F, 17F); AutoScaleDimensions = new SizeF(7F, 17F);
@@ -1232,5 +1254,7 @@ namespace FATrace.App
private PictureBox pictureBox5; private PictureBox pictureBox5;
private Label label31; private Label label31;
private Button btnConfigSave; private Button btnConfigSave;
private TextBox txtSolidBeveBatch;
private Label label33;
} }
} }

View File

@@ -255,7 +255,7 @@ namespace FATrace.App
ListRawCtrInfo = new List<RawCtrInfo>() ListRawCtrInfo = new List<RawCtrInfo>()
{ {
new RawCtrInfo(){ new RawCtrInfo(){
RawName="瑞士乳杆菌GCL1815", RawName="瑞士乳杆菌(固体饮料)",
RawCode="1121000265", RawCode="1121000265",
BtnControlName="btnRawName1", BtnControlName="btnRawName1",
RawSource=RawSource.Japan RawSource=RawSource.Japan
@@ -463,6 +463,7 @@ namespace FATrace.App
txtWeight.Text = CurSelectedRawProInput.Weight.ToString(); txtWeight.Text = CurSelectedRawProInput.Weight.ToString();
txtBatch.Text = CurSelectedRawProInput.Batch!; txtBatch.Text = CurSelectedRawProInput.Batch!;
txtSolidBeveBatch.Text = CurSelectedRawProInput.SolidBeveBatch ?? "";
txtShelfLife.Text = CurSelectedRawProInput.ShelfLife.ToString(); txtShelfLife.Text = CurSelectedRawProInput.ShelfLife.ToString();
txtRemainWeight.Text = CurSelectedRawProInput.RemainWeight.ToString(); txtRemainWeight.Text = CurSelectedRawProInput.RemainWeight.ToString();
@@ -572,6 +573,7 @@ namespace FATrace.App
// 2) 读取并校验输入框 // 2) 读取并校验输入框
var weightText = (txtWeight.Text ?? string.Empty).Trim(); var weightText = (txtWeight.Text ?? string.Empty).Trim();
var batchText = (txtBatch.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(); var shelfLifeText = (txtShelfLife.Text ?? string.Empty).Trim();
if (string.IsNullOrWhiteSpace(weightText) || if (string.IsNullOrWhiteSpace(weightText) ||
@@ -596,6 +598,19 @@ namespace FATrace.App
return; 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) || if (string.IsNullOrWhiteSpace(shelfLifeText) ||
!int.TryParse(shelfLifeText.Replace('', '.').Replace('。', '.'), out var shelfLife) || shelfLife <= 0) !int.TryParse(shelfLifeText.Replace('', '.').Replace('。', '.'), out var shelfLife) || shelfLife <= 0)
{ {
@@ -612,6 +627,7 @@ namespace FATrace.App
RawCode = CurSelectedRawProInput.RawCode, RawCode = CurSelectedRawProInput.RawCode,
Weight = Math.Round(weight, 2), // 保留3位小数避免浮点抖动 Weight = Math.Round(weight, 2), // 保留3位小数避免浮点抖动
Batch = batchText, Batch = batchText,
SolidBeveBatch = solidBeveBatchText,
ShelfLife = shelfLife, ShelfLife = shelfLife,
RawSource = CurSelectedRawProInput.RawSource, RawSource = CurSelectedRawProInput.RawSource,
RemainWeight = Math.Round(weight, 2), RemainWeight = Math.Round(weight, 2),
@@ -687,7 +703,7 @@ namespace FATrace.App
MessageBox.Show("请先选择要称重的产品", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("请先选择要称重的产品", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return; 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); MessageBox.Show("选择的产品信息无数据,请信息输入后再操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return; return;
@@ -736,15 +752,21 @@ namespace FATrace.App
txtRemainWeight.Text = NewRemainWeight.ToString(); 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 try
{ {
UpdateStatusLabel(tslPrintState, "正在打印...", Color.Goldenrod, Color.White); UpdateStatusLabel(tslPrintState, "正在打印...", Color.Goldenrod, Color.White);
CurZebraPrint.PrintWeight(Code, CurSelectedRawProInput.RawName!, CurZebraPrint.PrintWeight(Code, GetSimpleCode(Code), CurSelectedRawProInput.RawName!,
CurWeight, CurWeight,
CurSelectedRawProInput.Batch!, CurSelectedRawProInput.Batch!,
solidBeveBatchForCode,
CurSelectedRawProInput.ShelfLife CurSelectedRawProInput.ShelfLife
); );
SetPrinterStatusOk("打印成功"); SetPrinterStatusOk("打印成功");
@@ -765,6 +787,7 @@ namespace FATrace.App
var Result = FSqlContext.FDb.Insert<RawProUse>(new RawProUse() var Result = FSqlContext.FDb.Insert<RawProUse>(new RawProUse()
{ {
Batch = CurSelectedRawProInput.Batch, Batch = CurSelectedRawProInput.Batch,
SolidBeveBatch = solidBeveBatchForCode,
InBagCode = Code, InBagCode = Code,
BoxCode = Code + ",A", BoxCode = Code + ",A",
OpUser = CurrentOpUserNo, OpUser = CurrentOpUserNo,
@@ -833,6 +856,34 @@ namespace FATrace.App
} }
} }
/// <summary>
/// 获取简单的条码
/// 只要原料编码,批次,序号
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
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}";
}
/// <summary> /// <summary>
/// 格式化重量显示自动适配整数部分位数2-4位小数部分固定2位 /// 格式化重量显示自动适配整数部分位数2-4位小数部分固定2位
/// </summary> /// </summary>
@@ -900,6 +951,7 @@ namespace FATrace.App
{ {
txtWeight.Text = ""; txtWeight.Text = "";
txtBatch.Text = ""; txtBatch.Text = "";
txtSolidBeveBatch.Text = "";
txtShelfLife.Text = ""; txtShelfLife.Text = "";
txtRemainWeight.Text = ""; txtRemainWeight.Text = "";
} }
@@ -924,7 +976,7 @@ namespace FATrace.App
/// 生成条码信息 /// 生成条码信息
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
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(); var Code = new StringBuilder();
@@ -932,6 +984,8 @@ namespace FATrace.App
Code.Append(','); Code.Append(',');
Code.Append(Batch); Code.Append(Batch);
Code.Append(','); Code.Append(',');
Code.Append(SolidBeveBatch);
Code.Append(',');
Code.Append(FormatWeight(Weight).ToString().Replace(".", "")); Code.Append(FormatWeight(Weight).ToString().Replace(".", ""));
Code.Append(','); Code.Append(',');
Code.Append(ShelfLife.ToString()); Code.Append(ShelfLife.ToString());
@@ -1351,9 +1405,10 @@ namespace FATrace.App
try try
{ {
UpdateStatusLabel(tslPrintState, "正在打印...", Color.Goldenrod, Color.White); UpdateStatusLabel(tslPrintState, "正在打印...", Color.Goldenrod, Color.White);
CurZebraPrint.PrintWeight(LastData.InBagCode!, CurSelectedRawProInput.RawName!, CurZebraPrint.PrintWeight(LastData.InBagCode!, GetSimpleCode(LastData.InBagCode!), CurSelectedRawProInput.RawName!,
CurWeight, CurWeight,
CurSelectedRawProInput.Batch!, CurSelectedRawProInput.Batch!,
LastData.SolidBeveBatch ?? "",
CurSelectedRawProInput.ShelfLife CurSelectedRawProInput.ShelfLife
); );
SetPrinterStatusOk("打印成功"); SetPrinterStatusOk("打印成功");

View File

@@ -13,6 +13,31 @@ namespace FATrace.Com
/// </summary> /// </summary>
public class NVRCom public class NVRCom
{ {
private static string[] SplitCodeParts(string code)
{
if (string.IsNullOrWhiteSpace(code)) return Array.Empty<string>();
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();
}
/// <summary> /// <summary>
/// 获取视频名称 /// 获取视频名称
/// </summary> /// </summary>
@@ -65,15 +90,13 @@ namespace FATrace.Com
try try
{ {
// 标准化分隔符并切分:支持 英文逗号/中文逗号/分号/空格 var parts = SplitCodeParts(Code);
var normalized = Code.Trim()
.Replace('', ',') // 新二维码固定 7 段RawCode,Batch,SolidBeveBatch,Weight,ShelfLife,Region,DayCount
.Replace('', ',') if (parts.Length != 7)
.Replace(';', ','); {
var parts = normalized return (string.Empty, string.Empty, string.Empty);
.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries) }
.Select(p => p.Trim())
.ToArray();
string rawCode = parts.Length > 0 ? parts[0] : string.Empty; string rawCode = parts.Length > 0 ? parts[0] : string.Empty;
@@ -88,9 +111,10 @@ namespace FATrace.Com
// 重量3/4 位数字最后一位为小数位802 => 80.2g)。 // 重量3/4 位数字最后一位为小数位802 => 80.2g)。
string weight = string.Empty; 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) if (digits.Length >= 2)
{ {
// 在最后一位前插入小数点,如 802 => 80.21234 => 123.4 // 在最后一位前插入小数点,如 802 => 80.21234 => 123.4
@@ -118,14 +142,13 @@ namespace FATrace.Com
try try
{ {
var normalized = code.Trim() var parts = SplitCodeParts(code);
.Replace('', ',')
.Replace('', ',') // 新二维码固定 7 段RawCode,Batch,SolidBeveBatch,Weight,ShelfLife,Region,DayCount
.Replace(';', ','); if (parts.Length != 7)
var parts = normalized {
.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries) return result;
.Select(p => p.Trim()) }
.ToArray();
result.RawCode = parts.Length > 0 ? parts[0] : string.Empty; 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; 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; string weightStr = string.Empty;
if (digits.Length >= 2) 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 (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.RegionCode = digits;
result.RegionName = digits == "01" ? "国内" : (digits == "02" ? "日本" : "未知"); 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; if (int.TryParse(digits, out var c)) result.Count = c;
} }
} }

View File

@@ -17,6 +17,7 @@ namespace FATrace.Com
public string RawCode { get; set; } = string.Empty; public string RawCode { get; set; } = string.Empty;
public string RawName { get; set; } = string.Empty; public string RawName { get; set; } = string.Empty;
public string Batch { get; set; } = string.Empty; public string Batch { get; set; } = string.Empty;
public string SolidBeveBatch { get; set; } = string.Empty;
public decimal Weight { get; set; } public decimal Weight { get; set; }
public int ShelfLifeMonths { get; set; } public int ShelfLifeMonths { get; set; }
public string RegionCode { get; set; } = string.Empty; public string RegionCode { get; set; } = string.Empty;

View File

@@ -31,7 +31,12 @@ namespace FATrace.Model
/// <summary> /// <summary>
/// 批号 /// 批号
/// </summary> /// </summary>
public string Batch { get; set; } public string Batch { get; set; } = string.Empty;
/// <summary>
/// 固体饮料批次
/// </summary>
public string SolidBeveBatch { get; set; } = string.Empty;
/// <summary> /// <summary>
/// 重量(第三段解析后的实际数值,比如 802 -> 80.2 /// 重量(第三段解析后的实际数值,比如 802 -> 80.2
@@ -69,21 +74,28 @@ namespace FATrace.Model
} }
var parts = text.Split(','); 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 var model = new QRModel
{ {
RawText = text.Trim(), RawText = text.Trim(),
RawCode = parts[0].Trim(), RawCode = parts[0].Trim(),
Batch = parts[1].Trim(), Batch = parts[1].Trim(),
RawSource = parts[4].Trim() RawSource = parts[rawSourceIndex].Trim()
}; };
model.SolidBeveBatch = parts[2].Trim();
// 重量3/4 位数字,末位为小数位,例如 802 -> 80.2 // 重量3/4 位数字,末位为小数位,例如 802 -> 80.2
var weightCode = parts[2].Trim(); var weightCode = parts[weightIndex].Trim();
if (!int.TryParse(weightCode, out var weightInt)) if (!int.TryParse(weightCode, out var weightInt))
{ {
throw new ArgumentException($"重量段不是有效数字:{weightCode}", nameof(text)); throw new ArgumentException($"重量段不是有效数字:{weightCode}", nameof(text));
@@ -92,7 +104,7 @@ namespace FATrace.Model
model.Weight = weightInt / 10m; model.Weight = weightInt / 10m;
// 保质期(月) // 保质期(月)
var shelfText = parts[3].Trim(); var shelfText = parts[shelfLifeIndex].Trim();
if (!int.TryParse(shelfText, out var shelfMonths) || shelfMonths < 0) if (!int.TryParse(shelfText, out var shelfMonths) || shelfMonths < 0)
{ {
throw new ArgumentException($"保质期(月)不是有效数字:{shelfText}", nameof(text)); throw new ArgumentException($"保质期(月)不是有效数字:{shelfText}", nameof(text));
@@ -100,7 +112,7 @@ namespace FATrace.Model
model.ShelfLife = shelfMonths; model.ShelfLife = shelfMonths;
// 当日序号 // 当日序号
var seqText = parts[5].Trim(); var seqText = parts[seqIndex].Trim();
if (!int.TryParse(seqText, out var seq) || seq < 0) if (!int.TryParse(seqText, out var seq) || seq < 0)
{ {
throw new ArgumentException($"当日生产序号不是有效数字:{seqText}", nameof(text)); throw new ArgumentException($"当日生产序号不是有效数字:{seqText}", nameof(text));

View File

@@ -39,6 +39,12 @@ namespace FATrace.Model
[Column(Name = "Batch", IsNullable = false, StringLength = 50)] [Column(Name = "Batch", IsNullable = false, StringLength = 50)]
public string? Batch { get; set; } public string? Batch { get; set; }
/// <summary>
/// 固体饮料批次
/// </summary>
[Column(Name = "SolidBeveBatch", StringLength = 50)]
public string? SolidBeveBatch { get; set; }
/// <summary> /// <summary>
/// 保质期 年 /// 保质期 年
/// </summary> /// </summary>

View File

@@ -50,6 +50,12 @@ namespace FATrace.Model
[Column(Name = "Batch", IsNullable = false, StringLength = 50)] [Column(Name = "Batch", IsNullable = false, StringLength = 50)]
public string? Batch { get; set; } public string? Batch { get; set; }
/// <summary>
/// 固体饮料批次
/// </summary>
[Column(Name = "SolidBeveBatch", StringLength = 50)]
public string? SolidBeveBatch { get; set; }
/// <summary> /// <summary>
/// 配料日期 当天日期 /// 配料日期 当天日期
/// 年,月,日 /// 年,月,日

View File

@@ -30,15 +30,16 @@ namespace FATrace.WPLApp.CsvModel
Map(x => x.InBagCode).Index(2).Name("内袋二维码"); Map(x => x.InBagCode).Index(2).Name("内袋二维码");
Map(x => x.BoxCode).Index(3).Name("外箱二维码"); Map(x => x.BoxCode).Index(3).Name("外箱二维码");
Map(x => x.Batch).Index(4).Name("批号"); Map(x => x.Batch).Index(4).Name("批号");
Map(x => x.ShelfLife).Index(5).Name("保质期"); Map(x => x.SolidBeveBatch).Index(5).Name("固体饮料批次");
Map(x => x.Weight).Index(6).Name("称重重量(g)"); Map(x => x.ShelfLife).Index(6).Name("保质期");
Map(x => x.DeliveryDate).Index(7).Name("配料日期"); Map(x => x.Weight).Index(7).Name("称重重量(g)");
Map(x => x.RemainWeight).Index(8).Name("剩余重量(Kg)"); Map(x => x.DeliveryDate).Index(8).Name("配料日期");
Map(x => x.StockWeight).Index(9).Name("入库总重量(Kg)"); Map(x => x.RemainWeight).Index(9).Name("剩余重量(Kg)");
Map(x => x.WeightTime).Index(10).Name("称重时间").TypeConverterOption.Format("yyyy-MM-dd HH:mm:ss"); Map(x => x.StockWeight).Index(10).Name("入库总重量(Kg)");
Map(x => x.OpUser).Index(11).Name("操作者"); Map(x => x.WeightTime).Index(11).Name("称重时间").TypeConverterOption.Format("yyyy-MM-dd HH:mm:ss");
Map(x => x.CheckUser).Index(12).Name("确认者"); Map(x => x.OpUser).Index(12).Name("操作者");
Map(x => x.OutTime).Index(13).Name("外箱扫码时间").TypeConverterOption.Format("yyyy-MM-dd HH:mm:ss"); Map(x => x.CheckUser).Index(13).Name("确认者");
Map(x => x.OutTime).Index(14).Name("外箱扫码时间").TypeConverterOption.Format("yyyy-MM-dd HH:mm:ss");
} }
} }

View File

@@ -12,6 +12,7 @@ namespace FATrace.WPLApp.ModelDto
public string? RawName { get; set; } public string? RawName { get; set; }
public double Weight { get; set; } public double Weight { get; set; }
public string? Batch { get; set; } public string? Batch { get; set; }
public string? SolidBeveBatch { get; set; }
public int ShelfLife { get; set; } public int ShelfLife { get; set; }
public string RawSource { get; set; } = string.Empty; // 展示为文本 public string RawSource { get; set; } = string.Empty; // 展示为文本
public double RemainWeight { get; set; } public double RemainWeight { get; set; }

View File

@@ -39,6 +39,11 @@ namespace FATrace.WPLApp.ModelDto
/// </summary> /// </summary>
public string? Batch { get; set; } public string? Batch { get; set; }
/// <summary>
/// 固体饮料批次
/// </summary>
public string? SolidBeveBatch { get; set; }
/// <summary> /// <summary>
/// 配料日期 /// 配料日期
/// </summary> /// </summary>

View File

@@ -36,6 +36,11 @@ namespace FATrace.WPLApp.ModelDto
/// </summary> /// </summary>
public string? Batch { get; set; } public string? Batch { get; set; }
/// <summary>
/// 固体饮料批次
/// </summary>
public string? SolidBeveBatch { get; set; }
/// <summary> /// <summary>
/// 保质期 年 /// 保质期 年
/// </summary> /// </summary>

View File

@@ -68,6 +68,9 @@ namespace FATrace.WPLApp.ViewModels
public string? Batch { get => _batch; set { _batch = value; RaisePropertyChanged(); } } public string? Batch { get => _batch; set { _batch = value; RaisePropertyChanged(); } }
private string? _batch; private string? _batch;
public string? SolidBeveBatch { get => _solidBeveBatch; set { _solidBeveBatch = value; RaisePropertyChanged(); } }
private string? _solidBeveBatch;
/// <summary> /// <summary>
/// 原料来源(可空) /// 原料来源(可空)
/// </summary> /// </summary>
@@ -144,7 +147,7 @@ namespace FATrace.WPLApp.ViewModels
/// </summary> /// </summary>
private void ClearFilters() private void ClearFilters()
{ {
RawCode = RawName = Batch = string.Empty; RawCode = RawName = Batch = SolidBeveBatch = string.Empty;
SelectedRawSource = null; SelectedRawSource = null;
SelectedRawState = null; SelectedRawState = null;
StartTime = DateTime.Today; 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(RawCode)) q = q.Where(a => a.RawCode.Contains(RawCode));
if (!string.IsNullOrWhiteSpace(RawName)) q = q.Where(a => a.RawName.Contains(RawName)); 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(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 (SelectedRawSource.HasValue) q = q.Where(a => a.RawSource == SelectedRawSource.Value);
if (SelectedRawState.HasValue) q = q.Where(a => a.RawState == SelectedRawState.Value); if (SelectedRawState.HasValue) q = q.Where(a => a.RawState == SelectedRawState.Value);
@@ -206,6 +210,7 @@ namespace FATrace.WPLApp.ViewModels
RawName = a.RawName, RawName = a.RawName,
Weight = a.Weight, Weight = a.Weight,
Batch = a.Batch, Batch = a.Batch,
SolidBeveBatch = a.SolidBeveBatch,
ShelfLife = a.ShelfLife, ShelfLife = a.ShelfLife,
RawSource = a.RawSource.ToString(), RawSource = a.RawSource.ToString(),
RemainWeight = a.RemainWeight, RemainWeight = a.RemainWeight,
@@ -224,6 +229,7 @@ namespace FATrace.WPLApp.ViewModels
RawName = a.RawName, RawName = a.RawName,
Weight = a.Weight, Weight = a.Weight,
Batch = a.Batch, Batch = a.Batch,
SolidBeveBatch = a.SolidBeveBatch,
ShelfLife = a.ShelfLife, ShelfLife = a.ShelfLife,
RawSource = a.RawSource.ToString(), RawSource = a.RawSource.ToString(),
RemainWeight = a.RemainWeight, RemainWeight = a.RemainWeight,
@@ -287,7 +293,7 @@ namespace FATrace.WPLApp.ViewModels
var header = sheet.CreateRow(0); var header = sheet.CreateRow(0);
string[] headers = new[] string[] headers = new[]
{ {
"Id","原料编号","原料名称","入库重量(kg)","批号","保质期(年)","原料来源","剩余重量(kg)","分拆状态","创建时间" "Id","原料编号","原料名称","入库重量(kg)","批号","固体饮料批次","保质期(年)","原料来源","剩余重量(kg)","分拆状态","创建时间"
}; };
var headerFont = workbook.CreateFont(); var headerFont = workbook.CreateFont();
headerFont.IsBold = true; headerFont.IsBold = true;
@@ -321,6 +327,7 @@ namespace FATrace.WPLApp.ViewModels
row.CreateCell(c++).SetCellValue(it.RawName ?? string.Empty); row.CreateCell(c++).SetCellValue(it.RawName ?? string.Empty);
row.CreateCell(c++).SetCellValue(it.Weight); row.CreateCell(c++).SetCellValue(it.Weight);
row.CreateCell(c++).SetCellValue(it.Batch ?? 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.ShelfLife);
row.CreateCell(c++).SetCellValue(it.RawSource); row.CreateCell(c++).SetCellValue(it.RawSource);
row.CreateCell(c++).SetCellValue(it.RemainWeight); row.CreateCell(c++).SetCellValue(it.RemainWeight);

View File

@@ -129,6 +129,12 @@ namespace FATrace.WPLApp.ViewModels
/// </summary> /// </summary>
public string? Batch { get => _batch; set { _batch = value; RaisePropertyChanged(); } } public string? Batch { get => _batch; set { _batch = value; RaisePropertyChanged(); } }
private string? _solidBeveBatch;
/// <summary>
/// 固体饮料批次模糊匹配
/// </summary>
public string? SolidBeveBatch { get => _solidBeveBatch; set { _solidBeveBatch = value; RaisePropertyChanged(); } }
private string? _opUser; private string? _opUser;
/// <summary> /// <summary>
/// 操作者模糊匹配 /// 操作者模糊匹配
@@ -228,7 +234,7 @@ namespace FATrace.WPLApp.ViewModels
/// </summary> /// </summary>
private void ClearFilters() 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; StartTime = DateTime.Today;
EndTime = DateTime.Today.AddDays(1).AddSeconds(-1); EndTime = DateTime.Today.AddDays(1).AddSeconds(-1);
} }
@@ -277,6 +283,8 @@ namespace FATrace.WPLApp.ViewModels
q = q.Where(a => a.BoxCode.Contains(BoxCode)); q = q.Where(a => a.BoxCode.Contains(BoxCode));
if (!string.IsNullOrWhiteSpace(Batch)) if (!string.IsNullOrWhiteSpace(Batch))
q = q.Where(a => a.Batch.Contains(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)) if (!string.IsNullOrWhiteSpace(OpUser))
q = q.Where(a => a.OpUser.Contains(OpUser)); q = q.Where(a => a.OpUser.Contains(OpUser));
if (!string.IsNullOrWhiteSpace(CheckUser)) if (!string.IsNullOrWhiteSpace(CheckUser))
@@ -298,6 +306,7 @@ namespace FATrace.WPLApp.ViewModels
InBagCode = a.InBagCode, InBagCode = a.InBagCode,
BoxCode = a.BoxCode, BoxCode = a.BoxCode,
Batch = a.Batch, Batch = a.Batch,
SolidBeveBatch = a.SolidBeveBatch,
ShelfLife = a.ShelfLife, ShelfLife = a.ShelfLife,
Weight = a.Weight, Weight = a.Weight,
RemainWeight = a.RemainWeight, RemainWeight = a.RemainWeight,
@@ -322,6 +331,7 @@ namespace FATrace.WPLApp.ViewModels
InBagCode = a.InBagCode, InBagCode = a.InBagCode,
BoxCode = a.BoxCode, BoxCode = a.BoxCode,
Batch = a.Batch, Batch = a.Batch,
SolidBeveBatch = a.SolidBeveBatch,
ShelfLife = a.ShelfLife, ShelfLife = a.ShelfLife,
Weight = a.Weight, Weight = a.Weight,
RemainWeight = a.RemainWeight, RemainWeight = a.RemainWeight,
@@ -447,7 +457,7 @@ namespace FATrace.WPLApp.ViewModels
var header = sheet.CreateRow(0); var header = sheet.CreateRow(0);
string[] headers = new[] string[] headers = new[]
{ {
"Id","原料编号","原料名称","内袋二维码","外箱二维码","批号","保质期(年)", "Id","原料编号","原料名称","内袋二维码","外箱二维码","批号","固体饮料批次","保质期(年)",
"称重重量(g)","剩余重量(g)","入库总重量(g)","称重时间","操作者","确认者","出库时间","创建时间" "称重重量(g)","剩余重量(g)","入库总重量(g)","称重时间","操作者","确认者","出库时间","创建时间"
}; };
// 表头样式:加粗与更大字号 // 表头样式:加粗与更大字号
@@ -484,6 +494,7 @@ namespace FATrace.WPLApp.ViewModels
row.CreateCell(c++).SetCellValue(it.InBagCode ?? string.Empty); row.CreateCell(c++).SetCellValue(it.InBagCode ?? string.Empty);
row.CreateCell(c++).SetCellValue(it.BoxCode ?? string.Empty); row.CreateCell(c++).SetCellValue(it.BoxCode ?? string.Empty);
row.CreateCell(c++).SetCellValue(it.Batch ?? 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.ShelfLife);
row.CreateCell(c++).SetCellValue(it.Weight); row.CreateCell(c++).SetCellValue(it.Weight);
row.CreateCell(c++).SetCellValue(it.RemainWeight); row.CreateCell(c++).SetCellValue(it.RemainWeight);

View File

@@ -75,6 +75,14 @@
<TextBlock VerticalAlignment="Center" Text="批号:" /> <TextBlock VerticalAlignment="Center" Text="批号:" />
<TextBox Width="160" Text="{Binding Batch, UpdateSourceTrigger=PropertyChanged}" /> <TextBox Width="160" Text="{Binding Batch, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel> </StackPanel>
<StackPanel
Grid.Row="0"
Grid.Column="3"
Margin="0,0,10,8"
Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="固体饮料批次:" />
<TextBox Width="160" Text="{Binding SolidBeveBatch, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<!-- 第二行:来源/状态 --> <!-- 第二行:来源/状态 -->
<StackPanel <StackPanel
@@ -204,6 +212,10 @@
Width="120" Width="120"
Binding="{Binding Batch}" Binding="{Binding Batch}"
Header="批号" /> Header="批号" />
<DataGridTextColumn
Width="140"
Binding="{Binding SolidBeveBatch}"
Header="固体饮料批次" />
<DataGridTextColumn <DataGridTextColumn
Width="100" Width="100"
Binding="{Binding ShelfLife}" Binding="{Binding ShelfLife}"

View File

@@ -43,6 +43,7 @@
<ColumnDefinition Width="2*" /> <ColumnDefinition Width="2*" />
<ColumnDefinition Width="2*" /> <ColumnDefinition Width="2*" />
<ColumnDefinition Width="2*" /> <ColumnDefinition Width="2*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@@ -80,12 +81,20 @@
Grid.Column="3" Grid.Column="3"
Margin="0,0,10,8" Margin="0,0,10,8"
Orientation="Horizontal"> Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="固体饮料批次:" />
<TextBox Width="140" Text="{Binding SolidBeveBatch, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<StackPanel
Grid.Row="0"
Grid.Column="4"
Margin="0,0,10,8"
Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="操作者:" /> <TextBlock VerticalAlignment="Center" Text="操作者:" />
<TextBox Width="140" Text="{Binding OpUser, UpdateSourceTrigger=PropertyChanged}" /> <TextBox Width="140" Text="{Binding OpUser, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel> </StackPanel>
<StackPanel <StackPanel
Grid.Row="0" Grid.Row="0"
Grid.Column="4" Grid.Column="5"
Margin="0,0,10,8" Margin="0,0,10,8"
Orientation="Horizontal"> Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="确认者:" /> <TextBlock VerticalAlignment="Center" Text="确认者:" />
@@ -236,6 +245,10 @@
Width="120" Width="120"
Binding="{Binding Batch}" Binding="{Binding Batch}"
Header="批号" /> Header="批号" />
<DataGridTextColumn
Width="140"
Binding="{Binding SolidBeveBatch}"
Header="固体饮料批次" />
<DataGridTextColumn <DataGridTextColumn
Width="100" Width="100"
Binding="{Binding ShelfLife}" Binding="{Binding ShelfLife}"