Browse Source

wanfu 需求

master
robin 4 years ago
parent
commit
230b7b2838
6 changed files with 120 additions and 45 deletions
  1. +30
    -3
      ButcherFactory.BO/LocalBL/SegmentProductionBL.cs
  2. +7
    -8
      ButcherFactory.Form/Controls/CodePanel.Designer.cs
  3. +6
    -1
      ButcherFactory.Form/Controls/CodePanel.cs
  4. +2
    -1
      ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.Designer.cs
  5. +68
    -30
      ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs
  6. +7
    -2
      ButcherFactory.Form/SegmentProduction_/SegmentSumCodePrint.cs

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

@ -36,13 +36,14 @@ namespace ButcherFactory.BO.LocalBL
query.Columns.Add(DQSelectColumn.Field("ShotPrintName")); query.Columns.Add(DQSelectColumn.Field("ShotPrintName"));
query.Columns.Add(DQSelectColumn.Field("MainUnit")); query.Columns.Add(DQSelectColumn.Field("MainUnit"));
query.Columns.Add(DQSelectColumn.Field("TotalCode_ID")); query.Columns.Add(DQSelectColumn.Field("TotalCode_ID"));
query.Columns.Add(DQSelectColumn.Field("TotalCode_Code"));
query.Columns.Add(DQSelectColumn.Field("TotalCode_Code"));
query.Columns.Add(DQSelectColumn.Field("CreateTime"));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("InStored", false), DQCondition.EQ("Delete", false), DQCondition.EQ("Submited", submited))); query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("InStored", false), DQCondition.EQ("Delete", false), DQCondition.EQ("Submited", submited)));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true)); query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true));
if (submited) if (submited)
{ {
query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("CreateTime", DateTime.Today)); query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("CreateTime", DateTime.Today));
query.Range = SelectRange.Top(20);
query.Range = SelectRange.Top(50);
} }
var list = new BindingList<SegmentProduction>(); var list = new BindingList<SegmentProduction>();
using (var session = DmoSession.New()) using (var session = DmoSession.New())
@ -68,6 +69,7 @@ namespace ButcherFactory.BO.LocalBL
entity.MainUnit = (string)reader[12]; entity.MainUnit = (string)reader[12];
entity.TotalCode_ID = (long)reader[13]; entity.TotalCode_ID = (long)reader[13];
entity.TotalCode_Code = (string)reader[14]; entity.TotalCode_Code = (string)reader[14];
entity.CreateTime = (DateTime)reader[15];
list.Add(entity); list.Add(entity);
} }
} }
@ -76,6 +78,31 @@ namespace ButcherFactory.BO.LocalBL
return list; return list;
} }
public static BindingList<long?> GetInStoreList()
{
var query = new DQueryDom(new JoinAlias(typeof(SegmentProduction)));
query.Columns.Add(DQSelectColumn.Field("TotalCode_ID"));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("InStored", true) ));
query.GroupBy.Expressions.Add(DQExpression.Field("TotalCode_ID"));
query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("CreateTime", DateTime.Today));
var list = new BindingList<long?>();
using (var session = DmoSession.New())
{
using (var reader = session.ExecuteReader(query))
{
while (reader.Read())
{
list.Add((long)reader[0] );
}
}
}
return list;
}
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)));
@ -398,7 +425,7 @@ namespace ButcherFactory.BO.LocalBL
query.Columns.Add(DQSelectColumn.Field("StatisticNumber")); query.Columns.Add(DQSelectColumn.Field("StatisticNumber"));
query.Columns.Add(DQSelectColumn.Field("TotalCode_Code")); query.Columns.Add(DQSelectColumn.Field("TotalCode_Code"));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("Submited", true), DQCondition.EQ("Sync", false), DQCondition.EQ("Delete", false))); query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("Submited", true), DQCondition.EQ("Sync", false), DQCondition.EQ("Delete", false)));
//query.Where.Conditions.Add(DQCondition.LessThan("CreateTime", DateTime.Now.AddMinutes(-1)));
query.Where.Conditions.Add(DQCondition.LessThan("CreateTime", DateTime.Now.AddMinutes(-1)));
query.Range = SelectRange.Top(10); query.Range = SelectRange.Top(10);
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID")); query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID"));


+ 7
- 8
ButcherFactory.Form/Controls/CodePanel.Designer.cs View File

@ -37,21 +37,21 @@
this.flowLayoutPanel1.AutoScroll = true; this.flowLayoutPanel1.AutoScroll = true;
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 46);
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 50);
this.flowLayoutPanel1.Name = "flowLayoutPanel1"; this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(101, 552);
this.flowLayoutPanel1.Size = new System.Drawing.Size(105, 552);
this.flowLayoutPanel1.TabIndex = 0; this.flowLayoutPanel1.TabIndex = 0;
this.flowLayoutPanel1.WrapContents = false; this.flowLayoutPanel1.WrapContents = false;
// //
// Button // Button
// //
this.Button.BackColor = System.Drawing.Color.Violet;
this.Button.Font = new System.Drawing.Font("黑体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Button.BackColor = System.Drawing.Color.LightGray;
this.Button.Font = new System.Drawing.Font("黑体", 16F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Button.ForeColor = System.Drawing.Color.Black; this.Button.ForeColor = System.Drawing.Color.Black;
this.Button.Location = new System.Drawing.Point(3, 3); this.Button.Location = new System.Drawing.Point(3, 3);
this.Button.Name = "Button"; this.Button.Name = "Button";
this.Button.SelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(15)))), ((int)(((byte)(215)))), ((int)(((byte)(107)))));
this.Button.Size = new System.Drawing.Size(90, 40);
this.Button.SelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
this.Button.Size = new System.Drawing.Size(99, 40);
this.Button.TabIndex = 1; this.Button.TabIndex = 1;
this.Button.UseVisualStyleBackColor = false; this.Button.UseVisualStyleBackColor = false;
// //
@ -59,11 +59,10 @@
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.Controls.Add(this.Button); this.Controls.Add(this.Button);
this.Controls.Add(this.flowLayoutPanel1); this.Controls.Add(this.flowLayoutPanel1);
this.Name = "CodePanel"; this.Name = "CodePanel";
this.Size = new System.Drawing.Size(101, 598);
this.Size = new System.Drawing.Size(105, 602);
this.ResumeLayout(false); this.ResumeLayout(false);
} }


+ 6
- 1
ButcherFactory.Form/Controls/CodePanel.cs View File

@ -17,9 +17,14 @@ namespace ButcherFactory.Controls
InitializeComponent(); InitializeComponent();
} }
public void Add(Control v)
public void Add(Control v, bool top = false)
{ {
flowLayoutPanel1.Controls.Add(v); flowLayoutPanel1.Controls.Add(v);
if (top)
{
flowLayoutPanel1.Controls.SetChildIndex(v, 0);
}
} }
} }
} }

+ 2
- 1
ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.Designer.cs View File

@ -415,6 +415,7 @@
this.flowLayoutPanel3.AutoScroll = true; this.flowLayoutPanel3.AutoScroll = true;
this.flowLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill; this.flowLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel3.Location = new System.Drawing.Point(5, 19); this.flowLayoutPanel3.Location = new System.Drawing.Point(5, 19);
this.flowLayoutPanel3.Margin = new System.Windows.Forms.Padding(0);
this.flowLayoutPanel3.Name = "flowLayoutPanel3"; this.flowLayoutPanel3.Name = "flowLayoutPanel3";
this.flowLayoutPanel3.Size = new System.Drawing.Size(437, 357); this.flowLayoutPanel3.Size = new System.Drawing.Size(437, 357);
this.flowLayoutPanel3.TabIndex = 4; this.flowLayoutPanel3.TabIndex = 4;
@ -506,7 +507,7 @@
// colorButton1 // colorButton1
// //
this.colorButton1.BackColor = System.Drawing.Color.Blue; this.colorButton1.BackColor = System.Drawing.Color.Blue;
this.colorButton1.Font = new System.Drawing.Font("宋体", 13F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.colorButton1.Font = new System.Drawing.Font("宋体", 28F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.colorButton1.ForeColor = System.Drawing.Color.White; this.colorButton1.ForeColor = System.Drawing.Color.White;
this.colorButton1.Location = new System.Drawing.Point(13, 178); this.colorButton1.Location = new System.Drawing.Point(13, 178);
this.colorButton1.Name = "colorButton1"; this.colorButton1.Name = "colorButton1";


+ 68
- 30
ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs View File

@ -37,6 +37,7 @@ namespace ButcherFactory.SegmentProductionAuto_
Thread checkInStoreState; Thread checkInStoreState;
Thread initTask; Thread initTask;
BindingList<SegmentProduction> historyList; BindingList<SegmentProduction> historyList;
BindingList<long?> deleteList;
BindingList<TotalCode> allCode; BindingList<TotalCode> allCode;
Dictionary<string, List<ClientGoodsSet_Detail>> goodsSetDic; Dictionary<string, List<ClientGoodsSet_Detail>> goodsSetDic;
long? batchID; long? batchID;
@ -339,8 +340,8 @@ namespace ButcherFactory.SegmentProductionAuto_
entity.Goods_Spec = detail.Goods_Spec; entity.Goods_Spec = detail.Goods_Spec;
entity.MainUnit = detail.MainUnit; entity.MainUnit = detail.MainUnit;
entity.ShotPrintName = detail.ShotPrintName; entity.ShotPrintName = detail.ShotPrintName;
_codePanel.Add(initSegmentBt(entity));
_codePanel.Add(initSegmentBt(entity, _codePanel,_totalCode),true);
historyList.Insert(0, entity); historyList.Insert(0, entity);
@ -365,15 +366,17 @@ namespace ButcherFactory.SegmentProductionAuto_
SegmentProduction current; SegmentProduction current;
ColorButton _labelBt; ColorButton _labelBt;
private ColorButton initSegmentBt(SegmentProduction entity)
private ColorButton initSegmentBt(SegmentProduction entity, CodePanel parent, TotalCode tCode)
{ {
var bt = new ColorButton() { Text = entity.ShortCode }; var bt = new ColorButton() { Text = entity.ShortCode };
bt.Tag = entity; bt.Tag = entity;
bt.Width = 90;
bt.Width = 98;
bt.Height = 35; bt.Height = 35;
bt.Font = new Font("黑体", 13, FontStyle.Bold);
bt.BackColor = Color.DarkCyan;
bt.SelectedColor = Color.DarkOrange;
bt.Font = new Font("黑体", 15, FontStyle.Bold);
bt.ForeColor = Color.Black;
bt.BackColor = System.Drawing.SystemColors.ButtonFace;
bt.SelectedColor = Color.Cyan;
bt.Click += delegate bt.Click += delegate
{ {
bt.Selected = !bt.Selected; bt.Selected = !bt.Selected;
@ -387,8 +390,10 @@ namespace ButcherFactory.SegmentProductionAuto_
_codePanel.Button.Selected = false; _codePanel.Button.Selected = false;
_codePanel.Button.Invalidate(); _codePanel.Button.Invalidate();
} }
_totalCode = null;
_codePanel = null;
parent.Button.Selected = true;
parent.Button.Invalidate();
_totalCode = tCode;
_codePanel = parent;
} }
else else
{ {
@ -427,6 +432,7 @@ namespace ButcherFactory.SegmentProductionAuto_
void BindGrid() void BindGrid()
{ {
historyList = SegmentProductionBL.GetListByState(true); historyList = SegmentProductionBL.GetListByState(true);
deleteList = SegmentProductionBL.GetInStoreList();
allCode = SegmentProductionBL.GetTotalCode(DateTime.Now); allCode = SegmentProductionBL.GetTotalCode(DateTime.Now);
RefreshCodePanel(); RefreshCodePanel();
@ -442,12 +448,16 @@ namespace ButcherFactory.SegmentProductionAuto_
codeButtons.Clear(); codeButtons.Clear();
foreach (var item in allCode) foreach (var item in allCode)
{ {
var details = historyList.Where(x => x.TotalCode_ID == item.ID);
if (deleteList.Contains(item.ID))
{
continue;
}
var details = historyList.Where(x => x.TotalCode_ID == item.ID);
var n = new CodePanel(); var n = new CodePanel();
AddCodeButton(n, item); AddCodeButton(n, item);
foreach (var seg in details) foreach (var seg in details)
{ {
n.Add(initSegmentBt(seg));
n.Add(initSegmentBt(seg,n,item));
} }
flowLayoutPanel3.Controls.Add(n); flowLayoutPanel3.Controls.Add(n);
} }
@ -479,25 +489,47 @@ namespace ButcherFactory.SegmentProductionAuto_
if (netStateWatch1.NetState) if (netStateWatch1.NetState)
{ {
if (historyList.Any()) if (historyList.Any())
{
var arr = historyList.Reverse().Take(20);
{
int c = 50;
if (historyList.Count() < 50)
{
c = historyList.Count;
}
var arr = historyList.Reverse().Take(c);
var inStored = SegmentProductionBL.GetInStoreState(arr.Select(x => x.BarCode).ToList()); var inStored = SegmentProductionBL.GetInStoreState(arr.Select(x => x.BarCode).ToList());
var tag = arr.Where(x => inStored.Contains(x.BarCode)); var tag = arr.Where(x => inStored.Contains(x.BarCode));
if (tag.Any()) if (tag.Any())
{ {
SegmentProductionBL.SetInStored(tag.Select(x => x.ID).ToList()); SegmentProductionBL.SetInStored(tag.Select(x => x.ID).ToList());
this.Invoke(new Action(() => this.Invoke(new Action(() =>
{
{
var groupByTotal = tag.GroupBy(x => x.TotalCode_ID);
foreach (var item2 in groupByTotal)
{
var f = codeButtons.FirstOrDefault(x => ((TotalCode)x.Tag).ID == item2.Key);
if (f != null)
{
flowLayoutPanel3.Controls.Remove(f.Parent);
codeButtons.Remove(f);
}
}
foreach (var item in tag) foreach (var item in tag)
historyList.Remove(item);
//historyDataGrid.ClearSelection();
//historyDataGrid.Refresh();
historyList.Remove(item);
})); }));
} }
} }
} }
}
catch (Exception ex)
{
this.Invoke(new Action(() =>
{
msglbl.Text = "ERROR" + ex.Message ?? string.Empty;
}));
} }
catch { }
Thread.Sleep(5000); Thread.Sleep(5000);
} }
} }
@ -543,15 +575,12 @@ namespace ButcherFactory.SegmentProductionAuto_
private void deleteBtn_Click(object sender, EventArgs e) private void deleteBtn_Click(object sender, EventArgs e)
{ {
if (_totalCode == null || _codePanel == null)
{
if (current == null)
return;
//if (_totalCode == null || _codePanel == null)
if (current != null)
{
if (MessageBox.Show("确定删除选中记录?", "删除确认", MessageBoxButtons.OKCancel) != DialogResult.OK) if (MessageBox.Show("确定删除选中记录?", "删除确认", MessageBoxButtons.OKCancel) != DialogResult.OK)
return; return;
//var tag = historyDataGrid.SelectedRows[0].DataBoundItem as SegmentProduction;
if (current.CreateTime.AddMinutes(1) < DateTime.Now) if (current.CreateTime.AddMinutes(1) < DateTime.Now)
{ {
MessageBox.Show("已超出可删除时间范围"); MessageBox.Show("已超出可删除时间范围");
@ -565,15 +594,19 @@ namespace ButcherFactory.SegmentProductionAuto_
var parent=_labelBt.Parent; var parent=_labelBt.Parent;
parent.Controls.Remove(_labelBt); parent.Controls.Remove(_labelBt);
} }
//RefreshCodePanel();
var thd = new Thread(new ParameterizedThreadStart(RefreshTask)); var thd = new Thread(new ParameterizedThreadStart(RefreshTask));
thd.Start(d); thd.Start(d);
current = null; current = null;
} }
else
else if (_totalCode != null && _codePanel != null)
{ {
var deleteList = historyList.Where(x => x.TotalCode_ID == _totalCode.ID).ToList(); var deleteList = historyList.Where(x => x.TotalCode_ID == _totalCode.ID).ToList();
if (deleteList.Count > 0)
{
MessageBox.Show("总码下已有条码,不允许直接删除总码");
return;
}
SegmentProductionBL.DeleteTotalCode(_totalCode); SegmentProductionBL.DeleteTotalCode(_totalCode);
allCode.Remove(_totalCode); allCode.Remove(_totalCode);
codeButtons.Remove(_codePanel.Button); codeButtons.Remove(_codePanel.Button);
@ -683,10 +716,11 @@ namespace ButcherFactory.SegmentProductionAuto_
n.Button.Text = tCode.ShortCode; n.Button.Text = tCode.ShortCode;
n.Button.Click += delegate n.Button.Click += delegate
{ {
current = null;
n.Button.Selected = !n.Button.Selected; n.Button.Selected = !n.Button.Selected;
if (n.Button.Selected) if (n.Button.Selected)
{
{
current = null;
_codePanel = n; _codePanel = n;
_totalCode = tCode; _totalCode = tCode;
if (_labelBt != null) if (_labelBt != null)
@ -738,6 +772,10 @@ namespace ButcherFactory.SegmentProductionAuto_
if (dmos.Length == 0) if (dmos.Length == 0)
{ {
throw new Exception(string.Format("此码不包含任何产品!")); throw new Exception(string.Format("此码不包含任何产品!"));
}
foreach (var item in dmos)
{
item.TotalCode_Code = _totalCode.BarCode;
} }
NotAuto.SegmentSumCodePrint.Print(dmos, "SegmentSumCode.html"); NotAuto.SegmentSumCodePrint.Print(dmos, "SegmentSumCode.html");
var log = new SegmentLog(dmos[0].TotalCode_Code, "总码"); var log = new SegmentLog(dmos[0].TotalCode_Code, "总码");


+ 7
- 2
ButcherFactory.Form/SegmentProduction_/SegmentSumCodePrint.cs View File

@ -35,10 +35,15 @@ namespace ButcherFactory.SegmentProduction_
dic.Add("$Goods_Name", info); dic.Add("$Goods_Name", info);
dic.Add("$Date", DateTime.Now.ToString("yyyy/MM/dd HH:mm")); dic.Add("$Date", DateTime.Now.ToString("yyyy/MM/dd HH:mm"));
var code = entity.TotalCode_Code;
var code = entity.TotalCode_Code;
if (!string.IsNullOrEmpty(code))
{
if (code.Length > 6)
code = code.Substring(code.Length - 6);
}
dic.Add("$Code", code); dic.Add("$Code", code);
var imgUrl = string.Format(IMGFILE, id); var imgUrl = string.Format(IMGFILE, id);
var url = string.Format(AppContext.ConnectInfo.TraceBackUrl + "?code={0}",entity.TotalCode_Code);
var url = string.Format("{0}",entity.TotalCode_Code);
BwpClientPrint.BwpClientWebPrint.Create2DPic(url, imgUrl, 120); BwpClientPrint.BwpClientWebPrint.Create2DPic(url, imgUrl, 120);
dic.Add("$ImageUrl", imgUrl); dic.Add("$ImageUrl", imgUrl);


Loading…
Cancel
Save