Browse Source

...

qdwf_2864
Robin_PC\robin 2 days ago
parent
commit
7a53af858a
3 changed files with 118 additions and 98 deletions
  1. +2
    -2
      ButcherFactory.BO/LocalBL/SegmentProductionBL.cs
  2. +108
    -95
      ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs
  3. +8
    -1
      ButcherFactory.Login/app.config

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

@ -18,7 +18,7 @@ namespace ButcherFactory.BO.LocalBL
const string RpcPath = @"/MainSystem/B3ClientService/Rpcs/SegmentProductionRpc/"; const string RpcPath = @"/MainSystem/B3ClientService/Rpcs/SegmentProductionRpc/";
const string ProductTaskRpc = @"/MainSystem/B3Sale/Rpcs/SaleOutStoreRpc/GetSaleOutStoreNumber"; const string ProductTaskRpc = @"/MainSystem/B3Sale/Rpcs/SaleOutStoreRpc/GetSaleOutStoreNumber";
const string BatchProductTaskRpc = @"/MainSystem/B3Sale/Rpcs/SaleOutStoreRpc/BatchGetSaleOutStoreNumber"; const string BatchProductTaskRpc = @"/MainSystem/B3Sale/Rpcs/SaleOutStoreRpc/BatchGetSaleOutStoreNumber";
const string GetMinWeightMethod = @"/MainSystem/B3Sale/Rpcs/SaleOutStoreRpc/GetMinWeight";
const string GetMinWeightMethod = @"/MainSystem/B3ClientService/Rpcs/SegmentProductionRpc/GetMinWeight";
public static BindingList<SegmentProduction> GetListByState(bool submited) public static BindingList<SegmentProduction> GetListByState(bool submited)
{ {
@ -695,7 +695,7 @@ namespace ButcherFactory.BO.LocalBL
public static decimal GetMinWeight() public static decimal GetMinWeight()
{ {
return ButcherFactoryUtil.SecondUrlCall<decimal>(GetMinWeightMethod);
return RpcFacade.Call<decimal>(GetMinWeightMethod);
} }
} }


+ 108
- 95
ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs View File

@ -47,6 +47,12 @@ namespace ButcherFactory.SegmentProductionAuto_
NotAuto.SegmentProductionFormConfig config; NotAuto.SegmentProductionFormConfig config;
List<GoodsIdentify> identityList; List<GoodsIdentify> identityList;
List<string> specialGoodsCodes; List<string> specialGoodsCodes;
// 新增:窗体关闭标记,优雅退出后台线程
private bool _isFormClosing = false;
public WeightDetails mCache;
public SegmentProductionAutoForm() public SegmentProductionAutoForm()
{ {
InitializeComponent(); InitializeComponent();
@ -79,16 +85,16 @@ namespace ButcherFactory.SegmentProductionAuto_
void SegmentProductionAutoForm_FormClosing(object sender, FormClosingEventArgs e) void SegmentProductionAutoForm_FormClosing(object sender, FormClosingEventArgs e)
{ {
_isFormClosing = true;
// 取消Abort,改为Join等待线程自行退出
if (initTask != null && initTask.IsAlive) if (initTask != null && initTask.IsAlive)
initTask.Abort();
if (uploadData != null && uploadData.IsAlive)
uploadData.Abort();
initTask.Join(1000);
if (checkInStoreState != null && checkInStoreState.IsAlive) if (checkInStoreState != null && checkInStoreState.IsAlive)
checkInStoreState.Abort();
checkInStoreState.Join(1000);
if (uploadData != null && uploadData.IsAlive)
uploadData.Join(1000);
} }
public WeightDetails mCache;
protected override void OnLoad(EventArgs e) protected override void OnLoad(EventArgs e)
{ {
base.OnLoad(e); base.OnLoad(e);
@ -142,6 +148,7 @@ namespace ButcherFactory.SegmentProductionAuto_
{ {
while (!ok) while (!ok)
{ {
if (_isFormClosing) return;
try try
{ {
var changed = BaseInfoSyncRpc.SyncGoodsByTag(ApplyClient.分割品); var changed = BaseInfoSyncRpc.SyncGoodsByTag(ApplyClient.分割品);
@ -151,14 +158,18 @@ namespace ButcherFactory.SegmentProductionAuto_
ok = true; ok = true;
if (changed || !bind) if (changed || !bind)
BindBasicInfo(); BindBasicInfo();
this.Invoke(new Action(() =>
if (!this.IsDisposed && !this.Disposing)
{ {
msglbl.Text = string.Empty;
}));
this.Invoke(new Action(() =>
{
msglbl.Text = string.Empty;
}));
}
} }
catch (Exception ex) catch (Exception ex)
{ {
if (_isFormClosing) return;
if (!bind) if (!bind)
{ {
BindBasicInfo(); BindBasicInfo();
@ -166,7 +177,13 @@ namespace ButcherFactory.SegmentProductionAuto_
} }
var msg = ex.Message ?? string.Empty; var msg = ex.Message ?? string.Empty;
msglbl.Text = "ERROR:" + msg;
if (!this.IsDisposed && !this.Disposing)
{
this.Invoke(new Action(() =>
{
msglbl.Text = "ERROR:" + msg;
}));
}
LogUtil.WriteErrorFile(msg, "分割品车间称重计数"); LogUtil.WriteErrorFile(msg, "分割品车间称重计数");
} }
Thread.Sleep(500); Thread.Sleep(500);
@ -241,13 +258,8 @@ namespace ButcherFactory.SegmentProductionAuto_
} }
} }
var weight = uWeightControl1.Weight; var weight = uWeightControl1.Weight;
//#if DEBUG
// if (weight == 0)
// weight = (g.StandardWeightLow ?? 4.0m) + 0.1m;
//#endif
if (weight <= 0) if (weight <= 0)
{ {
//weight = 10;
MessageBox.Show("重量必须大于0"); MessageBox.Show("重量必须大于0");
return; return;
} }
@ -339,7 +351,7 @@ namespace ButcherFactory.SegmentProductionAuto_
bTag.Button.ForeColor = Color.White; bTag.Button.ForeColor = Color.White;
bTag.Button.Width = 140; bTag.Button.Width = 140;
bTag.Button.Height = 90; bTag.Button.Height = 90;
flowLayoutPanel2.Controls.Add(bTag); flowLayoutPanel2.Controls.Add(bTag);
} }
} }
@ -351,10 +363,6 @@ namespace ButcherFactory.SegmentProductionAuto_
var btn = sender as ColorButton; var btn = sender as ColorButton;
var detail = btn.Tag as ClientGoodsSet_Detail; var detail = btn.Tag as ClientGoodsSet_Detail;
var weight = uWeightControl1.Weight; var weight = uWeightControl1.Weight;
//#if DEBUG
// if (weight == 0)
// weight = (detail.StandardWeightLow ?? 4.0m) + 0.1m;
//#endif
if (weight <= 0) if (weight <= 0)
throw new Exception("重量必须大于0"); throw new Exception("重量必须大于0");
if (minWeight > 0 && weight < minWeight) if (minWeight > 0 && weight < minWeight)
@ -492,8 +500,6 @@ namespace ButcherFactory.SegmentProductionAuto_
historyList.Insert(0, entity); historyList.Insert(0, entity);
//if (historyList.Count > 30)
// historyList.RemoveAt(30);
if (barPrintCheck.Checked) if (barPrintCheck.Checked)
{ {
var template = config.Template; var template = config.Template;
@ -577,11 +583,14 @@ namespace ButcherFactory.SegmentProductionAuto_
{ {
var entity = obj as SegmentProduction; var entity = obj as SegmentProduction;
var list = SegmentProductionBL.GetProductTask(batchDate ?? DateTime.Today, entity); var list = SegmentProductionBL.GetProductTask(batchDate ?? DateTime.Today, entity);
this.Invoke(new Action(() =>
if (!this.IsDisposed && !this.Disposing)
{ {
taskDataGrid.DataSource = list;
taskDataGrid.Refresh();
}));
this.Invoke(new Action(() =>
{
taskDataGrid.DataSource = list;
taskDataGrid.Refresh();
}));
}
} }
List<ColorButton> codeButtons = new List<ColorButton>(0); List<ColorButton> codeButtons = new List<ColorButton>(0);
@ -630,6 +639,7 @@ namespace ButcherFactory.SegmentProductionAuto_
{ {
while (true) while (true)
{ {
if (_isFormClosing) return;
try try
{ {
if (netStateWatch1.NetState) if (netStateWatch1.NetState)
@ -637,10 +647,13 @@ namespace ButcherFactory.SegmentProductionAuto_
var msg = SegmentProductionBL.UploadSegmentInfo(true); var msg = SegmentProductionBL.UploadSegmentInfo(true);
if (!string.IsNullOrEmpty(msg) && msg.EndsWith("重复上传")) if (!string.IsNullOrEmpty(msg) && msg.EndsWith("重复上传"))
{ {
this.Invoke(new Action(() =>
if (!this.IsDisposed && !this.Disposing)
{ {
MessageBox.Show(msg + "请检查原因!");
}));
this.Invoke(new Action(() =>
{
MessageBox.Show(msg + "请检查原因!");
}));
}
} }
} }
} }
@ -656,6 +669,7 @@ namespace ButcherFactory.SegmentProductionAuto_
{ {
while (true) while (true)
{ {
if (_isFormClosing) return;
try try
{ {
if (netStateWatch1.NetState) if (netStateWatch1.NetState)
@ -673,92 +687,96 @@ namespace ButcherFactory.SegmentProductionAuto_
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(() =>
if (!this.IsDisposed && !this.Disposing)
{ {
var groupByTotal = tag.GroupBy(x => x.TotalCode_ID);
foreach (var item2 in groupByTotal)
this.Invoke(new Action(() =>
{ {
var d = item2.FirstOrDefault();
//鲜品不删除总码
if (d.GoodsType == 0)
var groupByTotal = tag.GroupBy(x => x.TotalCode_ID);
foreach (var item2 in groupByTotal)
{ {
if (_freshPanel != null)
var d = item2.FirstOrDefault();
if (d.GoodsType == 0)
{ {
var list = new List<ColorButton>();
foreach (var t in item2)
if (_freshPanel != null)
{ {
foreach (ColorButton item in flowLayoutPanel4.Controls)
var list = new List<ColorButton>();
foreach (var t in item2)
{ {
var tagItem = (SegmentProduction)item.Tag;
if (tagItem.BarCode == t.BarCode)
foreach (ColorButton item in flowLayoutPanel4.Controls)
{ {
list.Add(item);
break;
var tagItem = (SegmentProduction)item.Tag;
if (tagItem.BarCode == t.BarCode)
{
list.Add(item);
break;
}
} }
} }
foreach (var item in list)
{
flowLayoutPanel4.Controls.Remove(item);
}
} }
foreach (var item in list)
{
flowLayoutPanel4.Controls.Remove(item);
}
continue;
} }
continue;
}
else if (d.GoodsType == 1 && d.NoTotalCode)//暂存区不删除总码
{
if (_stayPanel != null)
else if (d.GoodsType == 1 && d.NoTotalCode)
{ {
var list = new List<ColorButton>();
foreach (var t in item2)
if (_stayPanel != null)
{ {
foreach (ColorButton item in flowLayoutPanel4.Controls)
var list = new List<ColorButton>();
foreach (var t in item2)
{ {
var tagItem = (SegmentProduction)item.Tag;
if (tagItem.BarCode == t.BarCode)
foreach (ColorButton item in flowLayoutPanel4.Controls)
{ {
list.Add(item);
break;
var tagItem = (SegmentProduction)item.Tag;
if (tagItem.BarCode == t.BarCode)
{
list.Add(item);
break;
}
} }
} }
foreach (var item in list)
{
flowLayoutPanel4.Controls.Remove(item);
}
} }
foreach (var item in list)
{
flowLayoutPanel4.Controls.Remove(item);
}
continue;
} }
continue;
}
var f = codeButtons.FirstOrDefault(x => ((TotalCode)x.Tag).ID == item2.Key);
if (f != null)
{
flowLayoutPanel3.Controls.Remove(f);
codeButtons.Remove(f);
}
if (_codePanel != null && _totalCode.ID == item2.Key)
{
flowLayoutPanel4.Controls.Clear();
_codePanel = null;
_totalCode = null;
var f = codeButtons.FirstOrDefault(x => ((TotalCode)x.Tag).ID == item2.Key);
if (f != null)
{
flowLayoutPanel3.Controls.Remove(f);
codeButtons.Remove(f);
}
if (_codePanel != null && _totalCode.ID == item2.Key)
{
flowLayoutPanel4.Controls.Clear();
_codePanel = null;
_totalCode = null;
}
foreach (var item in tag)
historyList.Remove(item);
} }
}
foreach (var item in tag)
historyList.Remove(item);
}));
}));
}
} }
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
this.Invoke(new Action(() =>
if (_isFormClosing) return;
if (!this.IsDisposed && !this.Disposing)
{ {
var msg = ex.Message ?? string.Empty;
msglbl.Text = "ERROR:" + msg;
LogUtil.WriteErrorFile(msg, "分割品车间称重计数");
}));
this.Invoke(new Action(() =>
{
var msg = ex.Message ?? string.Empty;
msglbl.Text = "ERROR:" + msg;
LogUtil.WriteErrorFile(msg, "分割品车间称重计数");
}));
}
} }
Thread.Sleep(5000); Thread.Sleep(5000);
} }
@ -821,7 +839,6 @@ 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) if (current != null)
{ {
if (MessageBox.Show("确定删除选中记录?", "删除确认", MessageBoxButtons.OKCancel) != DialogResult.OK) if (MessageBox.Show("确定删除选中记录?", "删除确认", MessageBoxButtons.OKCancel) != DialogResult.OK)
@ -873,7 +890,6 @@ namespace ButcherFactory.SegmentProductionAuto_
thd.Start(item); thd.Start(item);
} }
flowLayoutPanel3.Controls.Remove(_codePanel); flowLayoutPanel3.Controls.Remove(_codePanel);
// RefreshCodePanel();
current = null; current = null;
if (allCode.Count > 0) if (allCode.Count > 0)
{ {
@ -1039,11 +1055,8 @@ namespace ButcherFactory.SegmentProductionAuto_
n.BackColor = Color.LightGray; n.BackColor = Color.LightGray;
n.Font = new Font("黑体", 16F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); n.Font = new Font("黑体", 16F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
n.ForeColor = Color.Black; n.ForeColor = Color.Black;
// n.Location = new Point(3, 3);
//n.Name = "Button";
n.SelectedColor = Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); n.SelectedColor = Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
n.Size = new Size(99, 40); n.Size = new Size(99, 40);
//n.TabIndex = 1;
n.UseVisualStyleBackColor = false; n.UseVisualStyleBackColor = false;
codeButtons.Add(n); codeButtons.Add(n);
@ -1098,7 +1111,7 @@ namespace ButcherFactory.SegmentProductionAuto_
} }
private void butcherDateBox_MouseClick(object sender, MouseEventArgs e)
private void butcherDateBox_MouseClick(object sender, EventArgs e)
{ {
var simpleLbl = sender as Label; var simpleLbl = sender as Label;
var cs = new CalendarSelecter(); var cs = new CalendarSelecter();


+ 8
- 1
ButcherFactory.Login/app.config View File

@ -1,3 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>

Loading…
Cancel
Save