Browse Source

需求单No.158297 2、“分割车间称重计数客户端”打印出的条码,当{存货分类}=冻品 调取的打码格式(见附件:SegmentProductionPrint1.html) 时 打印{自定义执行标准}

master
yibo 4 years ago
parent
commit
74ca85965c
7 changed files with 160 additions and 128 deletions
  1. +5
    -1
      ButcherFactory.BO/BaseInfo/ClientGoodsSet.cs
  2. +2
    -0
      ButcherFactory.BO/BaseInfo/Goods.cs
  3. +5
    -3
      ButcherFactory.BO/LocalBL/FormClientGoodsSetBL.cs
  4. +3
    -2
      ButcherFactory.BO/LocalBL/SegmentProductionBL.cs
  5. +136
    -117
      ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs
  6. +2
    -2
      ButcherFactory.Form/SegmentProduction_/SegmentProductionForm.cs
  7. +7
    -3
      ButcherFactory.Form/SegmentProduction_/SegmentProductionPrint.cs

+ 5
- 1
ButcherFactory.BO/BaseInfo/ClientGoodsSet.cs View File

@ -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; }


+ 2
- 0
ButcherFactory.BO/BaseInfo/Goods.cs View File

@ -29,5 +29,7 @@ namespace ButcherFactory.BO
[DbColumn(DefaultValue = 0)]
public bool NoTotalCode { get; set; }
public string CustomerDefine { get; set; }
}
}

+ 5
- 3
ButcherFactory.BO/LocalBL/FormClientGoodsSetBL.cs View File

@ -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


+ 3
- 2
ButcherFactory.BO/LocalBL/SegmentProductionBL.cs View File

@ -188,12 +188,13 @@ namespace ButcherFactory.BO.LocalBL
return list;
}
public static short? GetGoodsType(long goodsID)
public static Tuple<short?,string> 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<short?>();
query.Columns.Add(DQSelectColumn.Field("CustomerDefine"));
return query.EExecuteScalar<short?,string>();
}
public static SegmentProduction Insert(long goodsID, decimal weight, long? workUnitID, long productBatchID, DateTime batchDate)


+ 136
- 117
ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs View File

@ -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);


+ 2
- 2
ButcherFactory.Form/SegmentProduction_/SegmentProductionForm.cs View File

@ -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, "","");
}
}


+ 7
- 3
ButcherFactory.Form/SegmentProduction_/SegmentProductionPrint.cs View File

@ -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;


Loading…
Cancel
Save