Browse Source

add xianpin

master
robin 4 years ago
parent
commit
4f91b02bee
4 changed files with 142 additions and 41 deletions
  1. +5
    -1
      ButcherFactory.BO/Bill/SegmentProduction.cs
  2. +7
    -1
      ButcherFactory.BO/Bill/TotalCode.cs
  3. +49
    -7
      ButcherFactory.BO/LocalBL/SegmentProductionBL.cs
  4. +81
    -32
      ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs

+ 5
- 1
ButcherFactory.BO/Bill/SegmentProduction.cs View File

@ -57,7 +57,11 @@ namespace ButcherFactory.BO
[ReferenceTo(typeof(Goods), "Code")] [ReferenceTo(typeof(Goods), "Code")]
[Join("Goods_ID", "ID")] [Join("Goods_ID", "ID")]
public string Goods_Code { get; set; }
public string Goods_Code { get; set; }
[ReferenceTo(typeof(Goods), "GoodsType")]
[Join("Goods_ID", "ID")]
public short? GoodsType { get; set; }
public long? GroupID { get; set; } public long? GroupID { get; set; }


+ 7
- 1
ButcherFactory.BO/Bill/TotalCode.cs View File

@ -12,7 +12,13 @@ namespace ButcherFactory.BO
public class TotalCode : SyncBill public class TotalCode : SyncBill
{ {
public string BarCode { get; set; } public string BarCode { get; set; }
private short _goodsType=1;
[DbColumn(DefaultValue = 1)]
public short GoodsType {
get { return _goodsType; }
set { _goodsType = value; }
}
[NonDmoProperty] [NonDmoProperty]
public string ShortCode public string ShortCode


+ 49
- 7
ButcherFactory.BO/LocalBL/SegmentProductionBL.cs View File

@ -105,15 +105,16 @@ namespace ButcherFactory.BO.LocalBL
public static BindingList<TotalCode> GetTotalCode( DateTime date) public static BindingList<TotalCode> GetTotalCode( DateTime date)
{ {
var query = new DQueryDom(new JoinAlias(typeof(TotalCode)));
var query = new DQueryDom(new JoinAlias(typeof(TotalCode)));
query.Columns.Add(DQSelectColumn.Field("ID")); query.Columns.Add(DQSelectColumn.Field("ID"));
query.Columns.Add(DQSelectColumn.Field("RowIndex")); query.Columns.Add(DQSelectColumn.Field("RowIndex"));
query.Columns.Add(DQSelectColumn.Field("BarCode")); query.Columns.Add(DQSelectColumn.Field("BarCode"));
query.Columns.Add(DQSelectColumn.Field("GoodsType"));
query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("CreateTime", date.Date)); query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("CreateTime", date.Date));
query.Where.Conditions.Add(DQCondition.LessThan("CreateTime", date.Date.AddDays(1))); query.Where.Conditions.Add(DQCondition.LessThan("CreateTime", date.Date.AddDays(1)));
query.Where.Conditions.Add(DQCondition.And( DQCondition.EQ("Delete", false) ));
query.Where.Conditions.Add(DQCondition.And( DQCondition.EQ("Delete", false) ));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("GoodsType"));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID",true)); query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID",true));
var list = new BindingList<TotalCode>(); var list = new BindingList<TotalCode>();
using (var session = DmoSession.New()) using (var session = DmoSession.New())
{ {
@ -124,8 +125,8 @@ namespace ButcherFactory.BO.LocalBL
var entity = new TotalCode(); var entity = new TotalCode();
entity.ID = (long)reader[0]; entity.ID = (long)reader[0];
entity.RowIndex = (int?)reader[1]; entity.RowIndex = (int?)reader[1];
entity.BarCode = (string)reader[2];
entity.BarCode = (string)reader[2];
entity.GoodsType = (short)reader[3];
list.Add(entity); list.Add(entity);
} }
} }
@ -205,10 +206,51 @@ namespace ButcherFactory.BO.LocalBL
} }
} }
static int TotalCodeRowIndex( DateTime date, IDmoSession session)
public static TotalCode InitFreshTotalCode()
{
TotalCode entity = null;
var date = DateTime.Now;
using (var session = DmoSession.New())
{
var tuple = GetFreshTotalCode(date, session);
if (tuple == null)
{
entity = new TotalCode();
entity.UserID = AppContext.Worker.ID;
entity.GoodsType = 0;
entity.RowIndex = 1;
// 年月日+2位机器号
entity.BarCode = string.Format("{0:yyyyMMdd}{1}", date, AppContext.ConnectInfo.ClientCode);
session.Insert(entity);
session.Commit();
}
else
{
entity = new TotalCode();
entity.ID = tuple.Item1;
entity.BarCode = tuple.Item2;
entity.GoodsType = 0;
}
} return entity;
}
static Tuple<long, string> GetFreshTotalCode(DateTime date, IDmoSession session)
{
var query = new DQueryDom(new JoinAlias("_main", typeof(TotalCode)));
query.Columns.Add(DQSelectColumn.Field("ID"));
query.Columns.Add(DQSelectColumn.Field("BarCode"));
query.Where.Conditions.Add(DQCondition.EQ("GoodsType", 0));
query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("CreateTime", date.Date));
query.Where.Conditions.Add(DQCondition.LessThan("CreateTime", date.Date.AddDays(1)));
return query.EExecuteScalar<long,string>(session) ;
}
static int TotalCodeRowIndex( DateTime date, IDmoSession session,short type=1)
{ {
var query = new DQueryDom(new JoinAlias("_main", typeof(TotalCode)));
var query = new DQueryDom(new JoinAlias("_main", typeof(TotalCode)));
query.Columns.Add(DQSelectColumn.Max("RowIndex")); query.Columns.Add(DQSelectColumn.Max("RowIndex"));
query.Where.Conditions.Add(DQCondition.EQ("GoodsType", type));
query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("CreateTime", date.Date)); query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("CreateTime", date.Date));
query.Where.Conditions.Add(DQCondition.LessThan("CreateTime", date.Date.AddDays(1))); query.Where.Conditions.Add(DQCondition.LessThan("CreateTime", date.Date.AddDays(1)));
return (query.EExecuteScalar<int?>(session) ?? 0) + 1; return (query.EExecuteScalar<int?>(session) ?? 0) + 1;


+ 81
- 32
ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs View File

@ -90,7 +90,8 @@ namespace ButcherFactory.SegmentProductionAuto_
if (checkInStoreState != null && checkInStoreState.IsAlive) if (checkInStoreState != null && checkInStoreState.IsAlive)
checkInStoreState.Abort(); checkInStoreState.Abort();
} }
public WeightDetails mCache;
public WeightDetails mCache;
protected override void OnLoad(EventArgs e) protected override void OnLoad(EventArgs e)
{ {
base.OnLoad(e); base.OnLoad(e);
@ -120,7 +121,7 @@ namespace ButcherFactory.SegmentProductionAuto_
mCache.Cache.Remove(v); mCache.Cache.Remove(v);
} }
wDic = mCache.Cache; wDic = mCache.Cache;
_freshTotalCode = SegmentProductionBL.InitFreshTotalCode();
} }
void LoadBind() void LoadBind()
@ -213,32 +214,46 @@ namespace ButcherFactory.SegmentProductionAuto_
{ {
bTag.Label.Text = string.Format("{0}-0", item.EachNumber.Value); bTag.Label.Text = string.Format("{0}-0", item.EachNumber.Value);
} }
ClientGoodsSet_Detail g = item;
bTag.Button.Click += delegate bTag.Button.Click += delegate
{ {
if (batchID == null)
throw new Exception("请先选择批次");
if (_totalCode == null || _codePanel == null)
if (batchID == null) {
MessageBox.Show("请先选择批次!");
return;
}
if (g.GoodsType == 1)
{ {
throw new Exception(string.Format("请先选择总码!"));
if (_totalCode == null || _codePanel == null)
{
MessageBox.Show("请先选择总码!");
return;
}
} }
var weight = uWeightControl1.Weight; var weight = uWeightControl1.Weight;
#if DEBUG #if DEBUG
if (weight == 0) if (weight == 0)
weight = (item.StandardWeightLow ?? 4.0m) + 0.1m;
weight = (g.StandardWeightLow ?? 4.0m) + 0.1m;
#endif #endif
if (weight == 0) if (weight == 0)
throw new Exception("重量不能为0");
if (item.StandardWeight.HasValue)
{
MessageBox.Show("重量不能为0");
return;
}
if (g.StandardWeight.HasValue)
{ {
if (weight < (item.StandardWeightLow ?? 0) || weight > (item.StandardWeightUp ?? 0))
throw new Exception(string.Format("重量必须在{0:#0.######}-{1:#0.######}之间", item.StandardWeightLow, item.StandardWeightUp));
weight = item.StandardWeight.Value;
if (weight < (g.StandardWeightLow ?? 0) || weight > (g.StandardWeightUp ?? 0))
{
MessageBox.Show(string.Format("重量必须在{0:#0.######}-{1:#0.######}之间", g.StandardWeightLow, g.StandardWeightUp));
return;
}
weight = g.StandardWeight.Value;
} }
List<decimal> l = null; List<decimal> l = null;
if (wDic.ContainsKey(item.Goods_ID))
if (wDic.ContainsKey(g.Goods_ID))
{ {
l = wDic[item.Goods_ID];
if (l.Count >= item.EachNumber.Value)
l = wDic[g.Goods_ID];
if (l.Count >= g.EachNumber.Value)
{ {
l.Clear(); l.Clear();
} }
@ -246,13 +261,13 @@ namespace ButcherFactory.SegmentProductionAuto_
} }
else else
{ {
wDic.Add(item.Goods_ID, l = new List<decimal>() { weight });
wDic.Add(g.Goods_ID, l = new List<decimal>() { weight });
} }
bTag.Label.MinCount = l.Count(); bTag.Label.MinCount = l.Count();
if (l.Count >= item.EachNumber.Value)
if (l.Count >= g.EachNumber.Value)
{ {
weight = l.Sum(x => x); weight = l.Sum(x => x);
InsertSegmentProduction(item, weight);
InsertSegmentProduction(g, weight);
} }
mCache.Cache = wDic; mCache.Cache = wDic;
XmlUtil.SerializerObjToFile(mCache); XmlUtil.SerializerObjToFile(mCache);
@ -261,9 +276,9 @@ namespace ButcherFactory.SegmentProductionAuto_
bTag.Label.Click += delegate bTag.Label.Click += delegate
{ {
List<decimal> l = new List<decimal>(0); List<decimal> l = new List<decimal>(0);
if (wDic.ContainsKey(item.Goods_ID))
if (wDic.ContainsKey(g.Goods_ID))
{ {
l = wDic[item.Goods_ID];
l = wDic[g.Goods_ID];
} }
new WeightView(this, bTag).ShowDialog(); new WeightView(this, bTag).ShowDialog();
}; };
@ -327,13 +342,33 @@ namespace ButcherFactory.SegmentProductionAuto_
entity.WorkUnit_ID = config.WorkUnitID; entity.WorkUnit_ID = config.WorkUnitID;
entity.ProductBatch_ID = batchID.Value; entity.ProductBatch_ID = batchID.Value;
entity.StandardPic = detail.StandardPic; entity.StandardPic = detail.StandardPic;
entity.GoodsType = detail.GoodsType;
if (!string.IsNullOrEmpty(statisticNumberBox.Text)) if (!string.IsNullOrEmpty(statisticNumberBox.Text))
entity.StatisticNumber = decimal.Parse(statisticNumberBox.Text); entity.StatisticNumber = decimal.Parse(statisticNumberBox.Text);
if (_totalCode == null || _codePanel==null)
TotalCode thisTotal = null;
CodePanel thisPanel;
if (entity.GoodsType == 0)
{ {
throw new Exception(string.Format("请先选择总码!" ));
entity.TotalCode_ID = _freshTotalCode.ID;
thisTotal = _freshTotalCode;
thisPanel = _freshPanel;
}
else
{
if (_totalCode == null || _codePanel == null)
{
throw new Exception(string.Format("请先选择总码!"));
}
if(_totalCode.GoodsType==0){
throw new Exception(string.Format("只有鲜品才可以选择鲜品总码!"));
}
entity.TotalCode_ID = _totalCode.ID;
thisTotal = _totalCode;
thisPanel = _codePanel;
} }
entity.TotalCode_ID = _totalCode.ID;
SegmentProductionBL.InsertAndSetGroupID(entity, batchDate.Value); SegmentProductionBL.InsertAndSetGroupID(entity, batchDate.Value);
entity.Goods_Code = detail.Goods_Code; entity.Goods_Code = detail.Goods_Code;
entity.Goods_Name = detail.Goods_Name; entity.Goods_Name = detail.Goods_Name;
@ -341,7 +376,7 @@ namespace ButcherFactory.SegmentProductionAuto_
entity.MainUnit = detail.MainUnit; entity.MainUnit = detail.MainUnit;
entity.ShotPrintName = detail.ShotPrintName; entity.ShotPrintName = detail.ShotPrintName;
_codePanel.Add(initSegmentBt(entity, _codePanel,_totalCode),true);
thisPanel.Add(initSegmentBt(entity, thisPanel, thisTotal), true);
historyList.Insert(0, entity); historyList.Insert(0, entity);
@ -448,10 +483,18 @@ namespace ButcherFactory.SegmentProductionAuto_
codeButtons.Clear(); codeButtons.Clear();
foreach (var item in allCode) foreach (var item in allCode)
{ {
if (deleteList.Contains(item.ID))
if (item.GoodsType == 0)
{
}
else
{ {
continue;
if (deleteList.Contains(item.ID))
{
continue;
}
} }
var details = historyList.Where(x => x.TotalCode_ID == item.ID); var details = historyList.Where(x => x.TotalCode_ID == item.ID);
var n = new CodePanel(); var n = new CodePanel();
AddCodeButton(n, item); AddCodeButton(n, item);
@ -468,12 +511,10 @@ namespace ButcherFactory.SegmentProductionAuto_
while (true) while (true)
{ {
try try
{
//this.Invoke(new Action(() =>
//{
{
if (netStateWatch1.NetState) if (netStateWatch1.NetState)
SegmentProductionBL.UploadSegmentInfo(); SegmentProductionBL.UploadSegmentInfo();
//}));
} }
catch { } catch { }
Thread.Sleep(2000); Thread.Sleep(2000);
@ -698,7 +739,9 @@ namespace ButcherFactory.SegmentProductionAuto_
} }
CodePanel _codePanel; CodePanel _codePanel;
CodePanel _freshPanel;
TotalCode _totalCode; TotalCode _totalCode;
TotalCode _freshTotalCode;
private void colorButton1_Click(object sender, EventArgs e) private void colorButton1_Click(object sender, EventArgs e)
{ {
var n = new CodePanel(); var n = new CodePanel();
@ -707,13 +750,19 @@ namespace ButcherFactory.SegmentProductionAuto_
allCode.Insert(0, tCode); allCode.Insert(0, tCode);
AddCodeButton(n, tCode,true); AddCodeButton(n, tCode,true);
flowLayoutPanel3.Controls.Add(n); flowLayoutPanel3.Controls.Add(n);
flowLayoutPanel3.Controls.SetChildIndex(n, 0);
flowLayoutPanel3.Controls.SetChildIndex(n, 1);
} }
private void AddCodeButton(CodePanel n, TotalCode tCode,bool add=false) private void AddCodeButton(CodePanel n, TotalCode tCode,bool add=false)
{ {
n.Button.Tag = tCode; n.Button.Tag = tCode;
n.Button.Text = tCode.ShortCode;
if (tCode.GoodsType == 0)
{
n.Button.Text ="鲜品";
_freshPanel = n;
}
else
n.Button.Text = tCode.ShortCode;
n.Button.Click += delegate n.Button.Click += delegate
{ {


Loading…
Cancel
Save