From 74ca85965caf97ea4d856c08fbc165da653c86ca Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Mon, 19 Jul 2021 09:25:13 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E6=B1=82=E5=8D=95No.158297=202?= =?UTF-8?q?=E3=80=81=E2=80=9C=E5=88=86=E5=89=B2=E8=BD=A6=E9=97=B4=E7=A7=B0?= =?UTF-8?q?=E9=87=8D=E8=AE=A1=E6=95=B0=E5=AE=A2=E6=88=B7=E7=AB=AF=E2=80=9D?= =?UTF-8?q?=E6=89=93=E5=8D=B0=E5=87=BA=E7=9A=84=E6=9D=A1=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E5=BD=93{=E5=AD=98=E8=B4=A7=E5=88=86=E7=B1=BB}=3D=E5=86=BB?= =?UTF-8?q?=E5=93=81=20=E8=B0=83=E5=8F=96=E7=9A=84=E6=89=93=E7=A0=81?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=EF=BC=88=E8=A7=81=E9=99=84=E4=BB=B6=EF=BC=9A?= =?UTF-8?q?SegmentProductionPrint1.html=EF=BC=89=20=E6=97=B6=20=E6=89=93?= =?UTF-8?q?=E5=8D=B0{=E8=87=AA=E5=AE=9A=E4=B9=89=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E6=A0=87=E5=87=86}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ButcherFactory.BO/BaseInfo/ClientGoodsSet.cs | 6 +- ButcherFactory.BO/BaseInfo/Goods.cs | 2 + .../LocalBL/FormClientGoodsSetBL.cs | 8 +- .../LocalBL/SegmentProductionBL.cs | 5 +- .../SegmentProductionAutoForm.cs | 253 ++++++++++-------- .../SegmentProductionForm.cs | 4 +- .../SegmentProductionPrint.cs | 10 +- 7 files changed, 160 insertions(+), 128 deletions(-) diff --git a/ButcherFactory.BO/BaseInfo/ClientGoodsSet.cs b/ButcherFactory.BO/BaseInfo/ClientGoodsSet.cs index a7ad3e1..5987470 100644 --- a/ButcherFactory.BO/BaseInfo/ClientGoodsSet.cs +++ b/ButcherFactory.BO/BaseInfo/ClientGoodsSet.cs @@ -51,7 +51,11 @@ namespace ButcherFactory.BO [ReferenceTo(typeof(Goods), "EachNumber")] [Join("Goods_ID", "ID")] - public int? EachNumber { get; set; } + public int? EachNumber { get; set; } + + [ReferenceTo(typeof(Goods), "CustomerDefine")] + [Join("Goods_ID", "ID")] + public string Goods_CustomerDefine { get; set; } public decimal? StandardWeight { get; set; } diff --git a/ButcherFactory.BO/BaseInfo/Goods.cs b/ButcherFactory.BO/BaseInfo/Goods.cs index 5e84e90..31ff863 100644 --- a/ButcherFactory.BO/BaseInfo/Goods.cs +++ b/ButcherFactory.BO/BaseInfo/Goods.cs @@ -29,5 +29,7 @@ namespace ButcherFactory.BO [DbColumn(DefaultValue = 0)] public bool NoTotalCode { get; set; } + + public string CustomerDefine { get; set; } } } diff --git a/ButcherFactory.BO/LocalBL/FormClientGoodsSetBL.cs b/ButcherFactory.BO/LocalBL/FormClientGoodsSetBL.cs index 245b5af..5c0c6e9 100644 --- a/ButcherFactory.BO/LocalBL/FormClientGoodsSetBL.cs +++ b/ButcherFactory.BO/LocalBL/FormClientGoodsSetBL.cs @@ -64,15 +64,16 @@ namespace ButcherFactory.BO.LocalBL query.Columns.Add(DQSelectColumn.Field("Goods_Name", detail)); query.Columns.Add(DQSelectColumn.Field("StandardWeight", detail)); query.Columns.Add(DQSelectColumn.Field("StandardWeightUp", detail)); - query.Columns.Add(DQSelectColumn.Field("StandardWeightLow", detail)); + query.Columns.Add(DQSelectColumn.Field("StandardWeightLow", detail));//5 query.Columns.Add(DQSelectColumn.Field("Goods_Spec", detail)); query.Columns.Add(DQSelectColumn.Field("Goods_Code", detail)); query.Columns.Add(DQSelectColumn.Field("GoodsType", detail)); query.Columns.Add(DQSelectColumn.Field("StandardPic", detail)); - query.Columns.Add(DQSelectColumn.Field("MainUnit", detail)); + query.Columns.Add(DQSelectColumn.Field("MainUnit", detail));//10 query.Columns.Add(DQSelectColumn.Field("ShotPrintName", detail)); query.Columns.Add(DQSelectColumn.Field("EachNumber", detail)); - query.Columns.Add(DQSelectColumn.Field("NoTotalCode", detail)); + query.Columns.Add(DQSelectColumn.Field("NoTotalCode", detail)); + query.Columns.Add(DQSelectColumn.Field("Goods_CustomerDefine", detail)); query.OrderBy.Expressions.Add(DQOrderByExpression.Create(main, "ID")); query.OrderBy.Expressions.Add(DQOrderByExpression.Create(detail, "ID")); @@ -99,6 +100,7 @@ namespace ButcherFactory.BO.LocalBL entity.ShotPrintName = (string)reader[11]; entity.EachNumber = (int?)reader[12]; entity.NoTotalCode = (bool)reader[13]; + entity.Goods_CustomerDefine = (string)reader[14]; if (result.ContainsKey(key)) result[key].Add(entity); else diff --git a/ButcherFactory.BO/LocalBL/SegmentProductionBL.cs b/ButcherFactory.BO/LocalBL/SegmentProductionBL.cs index 3bf9bee..39b2a36 100644 --- a/ButcherFactory.BO/LocalBL/SegmentProductionBL.cs +++ b/ButcherFactory.BO/LocalBL/SegmentProductionBL.cs @@ -188,12 +188,13 @@ namespace ButcherFactory.BO.LocalBL return list; } - public static short? GetGoodsType(long goodsID) + public static Tuple GetGoodsInfo(long goodsID) { var query = new DQueryDom(new JoinAlias(typeof(Goods))); query.Where.Conditions.Add(DQCondition.EQ("ID", goodsID)); query.Columns.Add(DQSelectColumn.Field("GoodsType")); - return query.EExecuteScalar(); + query.Columns.Add(DQSelectColumn.Field("CustomerDefine")); + return query.EExecuteScalar(); } public static SegmentProduction Insert(long goodsID, decimal weight, long? workUnitID, long productBatchID, DateTime batchDate) diff --git a/ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs b/ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs index a516fb0..38ed249 100644 --- a/ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs +++ b/ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs @@ -355,131 +355,141 @@ namespace ButcherFactory.SegmentProductionAuto_ } private void InsertSegmentProduction(ClientGoodsSet_Detail detail, decimal weight) - { - var pics = int.Parse(numberInput.Text); - if (pics <= 0) - pics = 1; - else if (pics > 50) - pics = 50; - SegmentProduction entity = null; - for (var i = 0; i < pics; i++) + { + var pics = int.Parse(numberInput.Text); + if (pics <= 0) + pics = 1; + else if (pics > 50) + pics = 50; + SegmentProduction entity = null; + for (var i = 0; i < pics; i++) + { + entity = new SegmentProduction(); + entity.Goods_ID = detail.Goods_ID; + entity.Weight = weight; + entity.WorkUnit_ID = config.WorkUnitID; + entity.ProductBatch_ID = batchID.Value; + entity.StandardPic = detail.StandardPic; + entity.GoodsType = detail.GoodsType; + entity.NoTotalCode = detail.NoTotalCode; + if (detail.SelectedIdentify != null) { - entity = new SegmentProduction(); - entity.Goods_ID = detail.Goods_ID; - entity.Weight = weight; - entity.WorkUnit_ID = config.WorkUnitID; - entity.ProductBatch_ID = batchID.Value; - entity.StandardPic = detail.StandardPic; - entity.GoodsType = detail.GoodsType; - entity.NoTotalCode = detail.NoTotalCode; - if (detail.SelectedIdentify != null) - { - entity.Identify = detail.SelectedIdentify.Identify; - entity.IdentifyRemark = detail.SelectedIdentify.Remark; - } - if (!string.IsNullOrEmpty(statisticNumberBox.Text)) - entity.StatisticNumber = decimal.Parse(statisticNumberBox.Text); + entity.Identify = detail.SelectedIdentify.Identify; + entity.IdentifyRemark = detail.SelectedIdentify.Remark; + } + if (!string.IsNullOrEmpty(statisticNumberBox.Text)) + entity.StatisticNumber = decimal.Parse(statisticNumberBox.Text); - TotalCode thisTotal = null; - ColorButton thisPanel; - bool rebuild = false; - if (entity.GoodsType == 0) + TotalCode thisTotal = null; + ColorButton thisPanel; + bool rebuild = false; + if (entity.GoodsType == 0) + { + entity.TotalCode_ID = _freshTotalCode.ID; + thisTotal = _freshTotalCode; + thisPanel = _freshPanel; + if (_totalCode == null || _totalCode.GoodsType != 0) + { + foreach (var bt in codeButtons) { - entity.TotalCode_ID = _freshTotalCode.ID; - thisTotal = _freshTotalCode; - thisPanel = _freshPanel; - if (_totalCode == null || _totalCode.GoodsType != 0) + if (bt.Selected) { - foreach (var bt in codeButtons) - { - if (bt.Selected) - { - bt.Selected = false; - bt.Invalidate(); - } - } - _codePanel = _freshPanel; - _codePanel.Selected = true; - _codePanel.Invalidate(); - _totalCode = _freshTotalCode; - rebuild = true; + bt.Selected = false; + bt.Invalidate(); } } - else if (entity.GoodsType == 1 && entity.NoTotalCode) + _codePanel = _freshPanel; + _codePanel.Selected = true; + _codePanel.Invalidate(); + _totalCode = _freshTotalCode; + rebuild = true; + } + } + else if (entity.GoodsType == 1 && entity.NoTotalCode) + { + entity.TotalCode_ID = _stayTotalCode.ID; + thisTotal = _stayTotalCode; + thisPanel = _stayPanel; + if (_totalCode == null || _totalCode.GoodsType != 1 || !_totalCode.NoTotalCode) + { + foreach (var bt in codeButtons) { - entity.TotalCode_ID = _stayTotalCode.ID; - thisTotal = _stayTotalCode; - thisPanel = _stayPanel; - if (_totalCode == null || _totalCode.GoodsType != 1 || !_totalCode.NoTotalCode) + if (bt.Selected) { - foreach (var bt in codeButtons) - { - if (bt.Selected) - { - bt.Selected = false; - bt.Invalidate(); - } - } - _codePanel = _stayPanel; - _codePanel.Selected = true; - _codePanel.Invalidate(); - _totalCode = _stayTotalCode; - rebuild = true; + bt.Selected = false; + bt.Invalidate(); } } - else - { - if (_totalCode == null || _codePanel == null) - { - throw new Exception(string.Format("请先选择总码!")); - } - if (_totalCode.GoodsType == 0) - { - throw new Exception(string.Format("只有鲜品才可以选择鲜品总码!")); - } - else if (_totalCode.GoodsType == 1 && _totalCode.NoTotalCode) - { - throw new Exception(string.Format("冻品只有暂存区产品才能选择暂存区!")); - } - entity.TotalCode_ID = _totalCode.ID; - thisTotal = _totalCode; - thisPanel = _codePanel; - } + _codePanel = _stayPanel; + _codePanel.Selected = true; + _codePanel.Invalidate(); + _totalCode = _stayTotalCode; + rebuild = true; + } + } + else + { + if (_totalCode == null || _codePanel == null) + { + throw new Exception(string.Format("请先选择总码!")); + } + if (_totalCode.GoodsType == 0) + { + throw new Exception(string.Format("只有鲜品才可以选择鲜品总码!")); + } + else if (_totalCode.GoodsType == 1 && _totalCode.NoTotalCode) + { + throw new Exception(string.Format("冻品只有暂存区产品才能选择暂存区!")); + } + entity.TotalCode_ID = _totalCode.ID; + thisTotal = _totalCode; + thisPanel = _codePanel; + } - SegmentProductionBL.InsertAndSetGroupID(entity, batchDate.Value); - entity.Goods_Code = detail.Goods_Code; - entity.Goods_Name = detail.Goods_Name; - entity.Goods_Spec = detail.Goods_Spec; - entity.MainUnit = detail.MainUnit; - entity.ShotPrintName = detail.ShotPrintName; - if(rebuild){ - BindflowLayoutPanel(thisPanel, thisTotal); - } - - var c = initSegmentBt(entity, thisPanel, thisTotal); - - flowLayoutPanel4.Controls.Add(c); - flowLayoutPanel4.Controls.SetChildIndex(c, 0); - - historyList.Insert(0, entity); + SegmentProductionBL.InsertAndSetGroupID(entity, batchDate.Value); + entity.Goods_Code = detail.Goods_Code; + entity.Goods_Name = detail.Goods_Name; + entity.Goods_Spec = detail.Goods_Spec; + entity.MainUnit = detail.MainUnit; + entity.ShotPrintName = detail.ShotPrintName; + if (rebuild) + { + BindflowLayoutPanel(thisPanel, thisTotal); + } + + var c = initSegmentBt(entity, thisPanel, thisTotal); + + flowLayoutPanel4.Controls.Add(c); + flowLayoutPanel4.Controls.SetChildIndex(c, 0); + + historyList.Insert(0, entity); - //if (historyList.Count > 30) - // historyList.RemoveAt(30); - if (barPrintCheck.Checked) + //if (historyList.Count > 30) + // historyList.RemoveAt(30); + if (barPrintCheck.Checked) + { + var template = config.Template; + string cd = null; + if (detail.GoodsType.HasValue) + { + if (detail.GoodsType == 0) + template = "SegmentProductionPrint.html"; + else { - var template = config.Template; - if (detail.GoodsType.HasValue) - template = detail.GoodsType == 0 ? "SegmentProductionPrint.html" : "SegmentProductionPrint1.html"; - NotAuto.SegmentProductionPrint.Print(entity, batchDate, template); - var log = new SegmentLog(entity.BarCode, "打印"); - log.Message = string.Format("存货名称:{0} 重量:{1:#0.###}", entity.Goods_Name, entity.Weight); - SegmentProductionBL.InsertLog(log); + cd = detail.Goods_CustomerDefine; + template = "SegmentProductionPrint1.html"; } + } + NotAuto.SegmentProductionPrint.Print(entity, batchDate, template, cd); + var log = new SegmentLog(entity.BarCode, "打印"); + log.Message = string.Format("存货名称:{0} 重量:{1:#0.###}", entity.Goods_Name, entity.Weight); + SegmentProductionBL.InsertLog(log); } - GoodsLabel.Text = detail.Goods_Name; - - var thd = new Thread(new ParameterizedThreadStart(RefreshTask)); - thd.Start(entity); + } + GoodsLabel.Text = detail.Goods_Name; + + var thd = new Thread(new ParameterizedThreadStart(RefreshTask)); + thd.Start(entity); } SegmentProduction current; @@ -741,16 +751,25 @@ namespace ButcherFactory.SegmentProductionAuto_ if (historyList.Count == 0) throw new Exception("请先选择要补打的记录"); SegmentProduction item; - + if (current != null) - item = current; + item = current; else - item = historyList.First(); + item = historyList.First(); var template = config.Template; - var goodsType = SegmentProductionBL.GetGoodsType(item.Goods_ID); - if (goodsType.HasValue) - template = goodsType == 0 ? "SegmentProductionPrint.html" : "SegmentProductionPrint1.html"; - NotAuto.SegmentProductionPrint.Print(item, batchDate, template); + var goodsInfo = SegmentProductionBL.GetGoodsInfo(item.Goods_ID); + string cd = null; + if (goodsInfo != null && goodsInfo.Item1.HasValue) + { + if (goodsInfo.Item1 == 0) + template = "SegmentProductionPrint.html"; + else + { + cd = goodsInfo.Item2; + template = "SegmentProductionPrint1.html"; + } + } + NotAuto.SegmentProductionPrint.Print(item, batchDate, template, cd); var log = new SegmentLog(item.BarCode, "补打"); log.Message = string.Format("存货名称:{0} 重量:{1:#0.###}", item.Goods_Name, item.Weight); SegmentProductionBL.InsertLog(log); diff --git a/ButcherFactory.Form/SegmentProduction_/SegmentProductionForm.cs b/ButcherFactory.Form/SegmentProduction_/SegmentProductionForm.cs index 00908df..3231663 100644 --- a/ButcherFactory.Form/SegmentProduction_/SegmentProductionForm.cs +++ b/ButcherFactory.Form/SegmentProduction_/SegmentProductionForm.cs @@ -166,7 +166,7 @@ namespace ButcherFactory.SegmentProduction_ historyDataGrid.FirstDisplayedScrollingRowIndex = 0; historyDataGrid.Refresh(); if (barPrintCheck.Checked) - SegmentProductionPrint.Print(entity, batchDate, ""); + SegmentProductionPrint.Print(entity, batchDate, "",""); } void BindGrid() @@ -282,7 +282,7 @@ namespace ButcherFactory.SegmentProduction_ if (historyDataGrid.CurrentRow == null) throw new Exception("请先选择要补打的记录"); var item = historyDataGrid.CurrentRow.DataBoundItem as SegmentProduction; - SegmentProductionPrint.Print(item, batchDate, ""); + SegmentProductionPrint.Print(item, batchDate, "",""); } } diff --git a/ButcherFactory.Form/SegmentProduction_/SegmentProductionPrint.cs b/ButcherFactory.Form/SegmentProduction_/SegmentProductionPrint.cs index eab197e..b0601f8 100644 --- a/ButcherFactory.Form/SegmentProduction_/SegmentProductionPrint.cs +++ b/ButcherFactory.Form/SegmentProduction_/SegmentProductionPrint.cs @@ -16,7 +16,7 @@ namespace ButcherFactory.SegmentProduction_ const string PRINTFILE = @"PrintTemplate\"; const string ENDFILE = @"PrintTemplate\SegmentProductionPrintEnd.html"; const string IMGFILE = @"TempImg\_img{0}.png"; - public static void Print(SegmentProduction entity, DateTime? dt, string template) + public static void Print(SegmentProduction entity, DateTime? dt, string template, string customerDefine) { if (AppContext.ConnectInfo.TraceBackUrl == "default") throw new Exception("请先配置追溯服务器地址"); @@ -32,6 +32,9 @@ namespace ButcherFactory.SegmentProduction_ info = string.Format("重量:{0:#0.##}{1}", entity.Weight, entity.MainUnit); dic.Add("$Info", info); dic.Add("$Date", dt.Value.ToString("yyyy/MM/dd")); + if (string.IsNullOrEmpty(customerDefine)) + customerDefine = "GB/T9959.2-2008"; + dic.Add("$CustomerDefine", customerDefine); var code = entity.BarCode; if (code.Length > 17) code = code.Substring(17); @@ -47,7 +50,8 @@ namespace ButcherFactory.SegmentProduction_ { BwpClientPrint.BwpClientWebPrint.CreateBarCode("69212203" + entity.Goods_Code, barImgUrl, new Size(120, 40)); } - catch (Exception ex){ + catch (Exception ex) + { if (ex.Message == "Contents do not pass checksum") { BwpClientPrint.BwpClientWebPrint.CreateBarCode("69738841" + entity.Goods_Code, barImgUrl, new Size(120, 40)); @@ -55,7 +59,7 @@ namespace ButcherFactory.SegmentProduction_ } dic.Add("$BarImg", barImgUrl); string unit = entity.MainUnit; - int rate =1; + int rate = 1; if (unit.ToUpper() == "KG") { rate = 1000;