using System; using ZJ_BYD.DB; using ZJ_BYD.Model; namespace ZJ_BYD.Untils { public class PrintHelper { /// /// 生成打印条码 /// /// /// /// /// /// /// public static (bool ok, string barCode,string num, string msg) PrintByHttp_2(string stationCode, T_MaskCode mskCode, bool autoPrint = true, int totalCount = 0) { string searialNum; //自动打印 if (autoPrint) { //查询当前机型当天已生产总数 totalCount = ResultHelper.QueryTotalCountByProductSfcCode(mskCode.ProductSfcCode, stationCode); //流水号 searialNum = ExtendMethod.NumFormat(totalCount + 1); } else { //流水号 searialNum = ExtendMethod.NumFormat(totalCount); } //年份代码 var strYear = DateTime.Now.ToString("yyyy"); var yearCode = YearHelper.QueryYearCode(strYear); int mouthInt = DateTime.Now.Month; //条码生成规则,10月为0,11月为A,12月为B。 string mouthStr; switch (mouthInt) { case 1: mouthStr = "1"; break; case 2: mouthStr = "2"; break; case 3: mouthStr = "3"; break; case 4: mouthStr = "4"; break; case 5: mouthStr = "5"; break; case 6: mouthStr = "6"; break; case 7: mouthStr = "7"; break; case 8: mouthStr = "8"; break; case 9: mouthStr = "9"; break; case 10: mouthStr = "0"; break; case 11: mouthStr = "A"; break; case 12: mouthStr = "B"; break; default: mouthStr = mouthInt.ToString(); break; } var barCode = $"{Program.areacode}{Program.deptcode}{mskCode.BarCodeChar}{yearCode}{mouthStr}{DateTime.Now.Day.ToString().PadLeft(2, '0')}{mskCode.PrintBarcode}{searialNum}"; return (true, barCode, searialNum, $"打印条码信息:{barCode}"); } } }