Commit edc4854e by 陶然

优化

parent 0f2fab40
...@@ -17,6 +17,7 @@ namespace Kivii.Client ...@@ -17,6 +17,7 @@ namespace Kivii.Client
public const string RouteSampleAssign = "/Restful/Kivii.Samples.Entities.Sample/Assign"; public const string RouteSampleAssign = "/Restful/Kivii.Samples.Entities.Sample/Assign";
public const string RouteSamplePackaging = "/Restful/Kivii.Samples.Entities.Sample/Packaging"; public const string RouteSamplePackaging = "/Restful/Kivii.Samples.Entities.Sample/Packaging";
public const string RouteSampleUnPackaging = "/Restful/Kivii.Samples.Entities.Sample/UnPackaging"; public const string RouteSampleUnPackaging = "/Restful/Kivii.Samples.Entities.Sample/UnPackaging";
public const string RouteOrganizationQuery = "/Restful/Kivii.Organizations.Entities.Organization/Query";
} }
} }
...@@ -232,6 +232,9 @@ namespace Kivii.Samples.Entities ...@@ -232,6 +232,9 @@ namespace Kivii.Samples.Entities
[Ignore] [Ignore]
public Sample CurrentPackage { get; set; } public Sample CurrentPackage { get; set; }
[Ignore]
public bool IsMatched { get; set; }
#region 创建/更新人V1.0 #region 创建/更新人V1.0
[ApiMember(Description = "创建人Kvid ")] [ApiMember(Description = "创建人Kvid ")]
[IgnoreUpdate] [IgnoreUpdate]
...@@ -473,4 +476,108 @@ namespace Kivii.Samples.Entities ...@@ -473,4 +476,108 @@ namespace Kivii.Samples.Entities
/// </summary> /// </summary>
Inbound = 200 Inbound = 200
} }
public class Organization : EntityWithMetadata, IEntityInPrimaryDb,
IEntityIsTree, IEntityHasRole, IEntityIsConfig
{
#region 关联信息
[DefaultEmptyGuid]
[ApiMember(Description = "父级Id")]
public Guid ParentKvid { get; set; }
#endregion
#region 名称信息
/// <summary>
/// 公司简称
/// </summary>
[ApiMember(Description = "机构简称")]
[Default("")]
[StringLength(200)]
public string Name { get; set; }
/// <summary>
/// 公司全称
/// </summary>
[ApiMember(Description = "机构全称", IsRequired = true)]
[Required]
[StringLength(200)]
[Unique]
public string FullName { get; set; }
/// <summary>
/// 助记码
/// </summary>
[StringLength(50)]
[Default("")]
[ApiMember(Description = "助 记 码")]
public string NameCode { get; set; }
#endregion
/// <summary>
/// 组织机构类型
/// </summary>
[StringLength(50)]
[IgnoreUpdate]
[Default("")]
[ApiMember(Description = "机构类型,分支机构,部门")]
public OrganizationType Type { get; set; }
/// <summary>
/// 内部编码,可以不填,一旦填写就要验证唯一性
/// </summary>
[StringLength(50)]
[Unique]
[Default("")]
[ApiMember(Description = "内部编码,可以不填,一旦填写就要验证唯一性")]
public string InternalCode { get; set; }
[Default("")]
[StringLength(50)]
[ApiMember(Description = "外部编码,其它系统导入的编码信息")]
public string RefId { get; set; }
/// <summary>
/// 部门电话
/// </summary>
[Default("")]
[ApiMember(Description = "联系电话")]
[StringLength(50)]
public string Telephone { get; set; }
/// <summary>
/// 公司地址
/// </summary>
[Default("")]
[StringLength(200)]
[ApiMember(Description = "机构地址")]
public string Address { get; set; }
/// <summary>
/// 排序号
/// </summary>
[Default(0)]
[ApiMember(Description = "排 序 号")]
public int SortId { get; set; }
//不使用,从系统层面已经分开各个组织机构了,一个域只能有一个组织机构
//[IgnoreUpdate]
//[CurrentOrganizationKvid]
//[ApiMember(Description = "根组织机构Id,根组织机构的Id和本属性值相同")]
//public Guid OrganizationKvid { get; set; }
}
public enum OrganizationType
{
Unsupported = 0,
Org,
Dept,
Virtual
}
} }
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
this.btnClearCurrentPackage = new System.Windows.Forms.Button(); this.btnClearCurrentPackage = new System.Windows.Forms.Button();
this.lbSetPackage = new System.Windows.Forms.Label(); this.lbSetPackage = new System.Windows.Forms.Label();
this.tbSetCurrentPackage = new System.Windows.Forms.TextBox(); this.tbSetCurrentPackage = new System.Windows.Forms.TextBox();
this.ckbAutoPackage = new System.Windows.Forms.CheckBox();
this.plLeft.SuspendLayout(); this.plLeft.SuspendLayout();
this.gbInfo.SuspendLayout(); this.gbInfo.SuspendLayout();
this.gbLogin.SuspendLayout(); this.gbLogin.SuspendLayout();
...@@ -98,7 +99,7 @@ ...@@ -98,7 +99,7 @@
this.plLeft.Dock = System.Windows.Forms.DockStyle.Left; this.plLeft.Dock = System.Windows.Forms.DockStyle.Left;
this.plLeft.Location = new System.Drawing.Point(0, 0); this.plLeft.Location = new System.Drawing.Point(0, 0);
this.plLeft.Name = "plLeft"; this.plLeft.Name = "plLeft";
this.plLeft.Size = new System.Drawing.Size(252, 667); this.plLeft.Size = new System.Drawing.Size(252, 659);
this.plLeft.TabIndex = 0; this.plLeft.TabIndex = 0;
// //
// gbInfo // gbInfo
...@@ -107,7 +108,7 @@ ...@@ -107,7 +108,7 @@
this.gbInfo.Dock = System.Windows.Forms.DockStyle.Fill; this.gbInfo.Dock = System.Windows.Forms.DockStyle.Fill;
this.gbInfo.Location = new System.Drawing.Point(0, 447); this.gbInfo.Location = new System.Drawing.Point(0, 447);
this.gbInfo.Name = "gbInfo"; this.gbInfo.Name = "gbInfo";
this.gbInfo.Size = new System.Drawing.Size(252, 220); this.gbInfo.Size = new System.Drawing.Size(252, 212);
this.gbInfo.TabIndex = 2; this.gbInfo.TabIndex = 2;
this.gbInfo.TabStop = false; this.gbInfo.TabStop = false;
this.gbInfo.Text = "信息"; this.gbInfo.Text = "信息";
...@@ -117,7 +118,7 @@ ...@@ -117,7 +118,7 @@
this.rtbMessage.Dock = System.Windows.Forms.DockStyle.Fill; this.rtbMessage.Dock = System.Windows.Forms.DockStyle.Fill;
this.rtbMessage.Location = new System.Drawing.Point(3, 17); this.rtbMessage.Location = new System.Drawing.Point(3, 17);
this.rtbMessage.Name = "rtbMessage"; this.rtbMessage.Name = "rtbMessage";
this.rtbMessage.Size = new System.Drawing.Size(246, 200); this.rtbMessage.Size = new System.Drawing.Size(246, 192);
this.rtbMessage.TabIndex = 0; this.rtbMessage.TabIndex = 0;
this.rtbMessage.Text = ""; this.rtbMessage.Text = "";
// //
...@@ -294,9 +295,9 @@ ...@@ -294,9 +295,9 @@
this.plRight.Controls.Add(this.gbRfid); this.plRight.Controls.Add(this.gbRfid);
this.plRight.Controls.Add(this.gbRightToolBar); this.plRight.Controls.Add(this.gbRightToolBar);
this.plRight.Dock = System.Windows.Forms.DockStyle.Right; this.plRight.Dock = System.Windows.Forms.DockStyle.Right;
this.plRight.Location = new System.Drawing.Point(659, 0); this.plRight.Location = new System.Drawing.Point(635, 0);
this.plRight.Name = "plRight"; this.plRight.Name = "plRight";
this.plRight.Size = new System.Drawing.Size(429, 667); this.plRight.Size = new System.Drawing.Size(450, 659);
this.plRight.TabIndex = 1; this.plRight.TabIndex = 1;
// //
// gbRfid // gbRfid
...@@ -305,7 +306,7 @@ ...@@ -305,7 +306,7 @@
this.gbRfid.Dock = System.Windows.Forms.DockStyle.Fill; this.gbRfid.Dock = System.Windows.Forms.DockStyle.Fill;
this.gbRfid.Location = new System.Drawing.Point(0, 125); this.gbRfid.Location = new System.Drawing.Point(0, 125);
this.gbRfid.Name = "gbRfid"; this.gbRfid.Name = "gbRfid";
this.gbRfid.Size = new System.Drawing.Size(429, 542); this.gbRfid.Size = new System.Drawing.Size(450, 534);
this.gbRfid.TabIndex = 2; this.gbRfid.TabIndex = 2;
this.gbRfid.TabStop = false; this.gbRfid.TabStop = false;
this.gbRfid.Text = "Rfid扫描结果"; this.gbRfid.Text = "Rfid扫描结果";
...@@ -328,9 +329,10 @@ ...@@ -328,9 +329,10 @@
this.dgvRfidSamples.Name = "dgvRfidSamples"; this.dgvRfidSamples.Name = "dgvRfidSamples";
this.dgvRfidSamples.ReadOnly = true; this.dgvRfidSamples.ReadOnly = true;
this.dgvRfidSamples.RowTemplate.Height = 23; this.dgvRfidSamples.RowTemplate.Height = 23;
this.dgvRfidSamples.Size = new System.Drawing.Size(423, 522); this.dgvRfidSamples.Size = new System.Drawing.Size(444, 514);
this.dgvRfidSamples.TabIndex = 0; this.dgvRfidSamples.TabIndex = 0;
this.dgvRfidSamples.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dgvRfidSamples_RowPostPaint); this.dgvRfidSamples.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dgvRfidSamples_RowPostPaint);
this.dgvRfidSamples.RowStateChanged += new System.Windows.Forms.DataGridViewRowStateChangedEventHandler(this.dgvRfidSamples_RowStateChanged);
// //
// dataGridViewTextBoxColumn1 // dataGridViewTextBoxColumn1
// //
...@@ -394,6 +396,7 @@ ...@@ -394,6 +396,7 @@
// //
// gbRightToolBar // gbRightToolBar
// //
this.gbRightToolBar.Controls.Add(this.ckbAutoPackage);
this.gbRightToolBar.Controls.Add(this.btnSampleAssign); this.gbRightToolBar.Controls.Add(this.btnSampleAssign);
this.gbRightToolBar.Controls.Add(this.lbTips); this.gbRightToolBar.Controls.Add(this.lbTips);
this.gbRightToolBar.Controls.Add(this.lbScanSample); this.gbRightToolBar.Controls.Add(this.lbScanSample);
...@@ -402,7 +405,7 @@ ...@@ -402,7 +405,7 @@
this.gbRightToolBar.Dock = System.Windows.Forms.DockStyle.Top; this.gbRightToolBar.Dock = System.Windows.Forms.DockStyle.Top;
this.gbRightToolBar.Location = new System.Drawing.Point(0, 0); this.gbRightToolBar.Location = new System.Drawing.Point(0, 0);
this.gbRightToolBar.Name = "gbRightToolBar"; this.gbRightToolBar.Name = "gbRightToolBar";
this.gbRightToolBar.Size = new System.Drawing.Size(429, 125); this.gbRightToolBar.Size = new System.Drawing.Size(450, 125);
this.gbRightToolBar.TabIndex = 1; this.gbRightToolBar.TabIndex = 1;
this.gbRightToolBar.TabStop = false; this.gbRightToolBar.TabStop = false;
this.gbRightToolBar.Text = "操作台"; this.gbRightToolBar.Text = "操作台";
...@@ -413,7 +416,7 @@ ...@@ -413,7 +416,7 @@
this.btnSampleAssign.Dock = System.Windows.Forms.DockStyle.Right; this.btnSampleAssign.Dock = System.Windows.Forms.DockStyle.Right;
this.btnSampleAssign.Font = new System.Drawing.Font("宋体", 29F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic)))); this.btnSampleAssign.Font = new System.Drawing.Font("宋体", 29F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))));
this.btnSampleAssign.ForeColor = System.Drawing.Color.DarkBlue; this.btnSampleAssign.ForeColor = System.Drawing.Color.DarkBlue;
this.btnSampleAssign.Location = new System.Drawing.Point(313, 17); this.btnSampleAssign.Location = new System.Drawing.Point(334, 17);
this.btnSampleAssign.Name = "btnSampleAssign"; this.btnSampleAssign.Name = "btnSampleAssign";
this.btnSampleAssign.Size = new System.Drawing.Size(113, 105); this.btnSampleAssign.Size = new System.Drawing.Size(113, 105);
this.btnSampleAssign.TabIndex = 84; this.btnSampleAssign.TabIndex = 84;
...@@ -448,7 +451,7 @@ ...@@ -448,7 +451,7 @@
this.tbScanSample.Font = new System.Drawing.Font("宋体", 18F); this.tbScanSample.Font = new System.Drawing.Font("宋体", 18F);
this.tbScanSample.Location = new System.Drawing.Point(7, 44); this.tbScanSample.Location = new System.Drawing.Point(7, 44);
this.tbScanSample.Name = "tbScanSample"; this.tbScanSample.Name = "tbScanSample";
this.tbScanSample.Size = new System.Drawing.Size(209, 35); this.tbScanSample.Size = new System.Drawing.Size(224, 35);
this.tbScanSample.TabIndex = 81; this.tbScanSample.TabIndex = 81;
this.tbScanSample.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbScanSample_KeyDown); this.tbScanSample.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbScanSample_KeyDown);
// //
...@@ -459,7 +462,7 @@ ...@@ -459,7 +462,7 @@
this.btnScanRfid.ForeColor = System.Drawing.Color.Chocolate; this.btnScanRfid.ForeColor = System.Drawing.Color.Chocolate;
this.btnScanRfid.Location = new System.Drawing.Point(7, 82); this.btnScanRfid.Location = new System.Drawing.Point(7, 82);
this.btnScanRfid.Name = "btnScanRfid"; this.btnScanRfid.Name = "btnScanRfid";
this.btnScanRfid.Size = new System.Drawing.Size(209, 40); this.btnScanRfid.Size = new System.Drawing.Size(224, 40);
this.btnScanRfid.TabIndex = 77; this.btnScanRfid.TabIndex = 77;
this.btnScanRfid.Text = "开始扫描"; this.btnScanRfid.Text = "开始扫描";
this.btnScanRfid.UseVisualStyleBackColor = false; this.btnScanRfid.UseVisualStyleBackColor = false;
...@@ -472,7 +475,7 @@ ...@@ -472,7 +475,7 @@
this.plMain.Dock = System.Windows.Forms.DockStyle.Fill; this.plMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.plMain.Location = new System.Drawing.Point(252, 0); this.plMain.Location = new System.Drawing.Point(252, 0);
this.plMain.Name = "plMain"; this.plMain.Name = "plMain";
this.plMain.Size = new System.Drawing.Size(407, 667); this.plMain.Size = new System.Drawing.Size(383, 659);
this.plMain.TabIndex = 2; this.plMain.TabIndex = 2;
// //
// gbMain // gbMain
...@@ -481,7 +484,7 @@ ...@@ -481,7 +484,7 @@
this.gbMain.Dock = System.Windows.Forms.DockStyle.Fill; this.gbMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.gbMain.Location = new System.Drawing.Point(0, 125); this.gbMain.Location = new System.Drawing.Point(0, 125);
this.gbMain.Name = "gbMain"; this.gbMain.Name = "gbMain";
this.gbMain.Size = new System.Drawing.Size(407, 542); this.gbMain.Size = new System.Drawing.Size(383, 534);
this.gbMain.TabIndex = 1; this.gbMain.TabIndex = 1;
this.gbMain.TabStop = false; this.gbMain.TabStop = false;
this.gbMain.Text = "箱内样品"; this.gbMain.Text = "箱内样品";
...@@ -504,9 +507,11 @@ ...@@ -504,9 +507,11 @@
this.dgvSamples.Name = "dgvSamples"; this.dgvSamples.Name = "dgvSamples";
this.dgvSamples.ReadOnly = true; this.dgvSamples.ReadOnly = true;
this.dgvSamples.RowTemplate.Height = 23; this.dgvSamples.RowTemplate.Height = 23;
this.dgvSamples.Size = new System.Drawing.Size(401, 522); this.dgvSamples.Size = new System.Drawing.Size(377, 514);
this.dgvSamples.TabIndex = 0; this.dgvSamples.TabIndex = 0;
this.dgvSamples.DataBindingComplete += new System.Windows.Forms.DataGridViewBindingCompleteEventHandler(this.dgvSamples_DataBindingComplete);
this.dgvSamples.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dgvSamples_RowPostPaint); this.dgvSamples.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dgvSamples_RowPostPaint);
this.dgvSamples.RowStateChanged += new System.Windows.Forms.DataGridViewRowStateChangedEventHandler(this.dgvSamples_RowStateChanged);
// //
// SampleBizId // SampleBizId
// //
...@@ -577,7 +582,7 @@ ...@@ -577,7 +582,7 @@
this.gbMainToolBar.Dock = System.Windows.Forms.DockStyle.Top; this.gbMainToolBar.Dock = System.Windows.Forms.DockStyle.Top;
this.gbMainToolBar.Location = new System.Drawing.Point(0, 0); this.gbMainToolBar.Location = new System.Drawing.Point(0, 0);
this.gbMainToolBar.Name = "gbMainToolBar"; this.gbMainToolBar.Name = "gbMainToolBar";
this.gbMainToolBar.Size = new System.Drawing.Size(407, 125); this.gbMainToolBar.Size = new System.Drawing.Size(383, 125);
this.gbMainToolBar.TabIndex = 0; this.gbMainToolBar.TabIndex = 0;
this.gbMainToolBar.TabStop = false; this.gbMainToolBar.TabStop = false;
this.gbMainToolBar.Text = "操作台"; this.gbMainToolBar.Text = "操作台";
...@@ -622,11 +627,21 @@ ...@@ -622,11 +627,21 @@
this.tbSetCurrentPackage.TabIndex = 78; this.tbSetCurrentPackage.TabIndex = 78;
this.tbSetCurrentPackage.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbSetCurrentPackage_KeyDown); this.tbSetCurrentPackage.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbSetCurrentPackage_KeyDown);
// //
// ckbAutoPackage
//
this.ckbAutoPackage.AutoSize = true;
this.ckbAutoPackage.Location = new System.Drawing.Point(237, 103);
this.ckbAutoPackage.Name = "ckbAutoPackage";
this.ckbAutoPackage.Size = new System.Drawing.Size(72, 16);
this.ckbAutoPackage.TabIndex = 85;
this.ckbAutoPackage.Text = "自动入箱";
this.ckbAutoPackage.UseVisualStyleBackColor = true;
//
// FrmMain // FrmMain
// //
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.ClientSize = new System.Drawing.Size(1088, 667); this.ClientSize = new System.Drawing.Size(1085, 659);
this.Controls.Add(this.plMain); this.Controls.Add(this.plMain);
this.Controls.Add(this.plRight); this.Controls.Add(this.plRight);
this.Controls.Add(this.plLeft); this.Controls.Add(this.plLeft);
...@@ -703,6 +718,7 @@ ...@@ -703,6 +718,7 @@
private System.Windows.Forms.ComboBox cbSetCurrentPackageOwner; private System.Windows.Forms.ComboBox cbSetCurrentPackageOwner;
private System.Windows.Forms.Label lbCurrentPackageStatus; private System.Windows.Forms.Label lbCurrentPackageStatus;
private System.Windows.Forms.Button btnSampleAssign; private System.Windows.Forms.Button btnSampleAssign;
private System.Windows.Forms.CheckBox ckbAutoPackage;
} }
} }
...@@ -11,6 +11,7 @@ using System.ComponentModel; ...@@ -11,6 +11,7 @@ using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
...@@ -25,12 +26,13 @@ namespace Kivii.Client.SampleInbounds ...@@ -25,12 +26,13 @@ namespace Kivii.Client.SampleInbounds
private Sample _currentPackage; private Sample _currentPackage;
private List<Sample> _currentPackageSamples; private List<Sample> _currentPackageSamples;
private List<Sample> _currentScanSamples; private List<Sample> _currentScanSamples;
private List<Organization> _currentOrgs;
private AuthenticateResponse _userInfo; private AuthenticateResponse _userInfo;
private Reader reader; private Reader reader;
private ReaderSetting currentSetting; private ReaderSetting currentSetting;
private InventoryBuffer currentInventoryBuffer; private InventoryBuffer currentInventoryBuffer;
private string defaultPort = "COM2"; private string defaultPort = "COM1";
private int defaultBaudrate = 115200; private int defaultBaudrate = 115200;
private bool isConnected = false; private bool isConnected = false;
...@@ -46,7 +48,6 @@ namespace Kivii.Client.SampleInbounds ...@@ -46,7 +48,6 @@ namespace Kivii.Client.SampleInbounds
private void FrmMain_Load(object sender, EventArgs e) private void FrmMain_Load(object sender, EventArgs e)
{ {
connectReader();
initControls(); initControls();
loadDefault(tbxServiceUrl, tbxUserName, tbxPassword); loadDefault(tbxServiceUrl, tbxUserName, tbxPassword);
} }
...@@ -76,8 +77,8 @@ namespace Kivii.Client.SampleInbounds ...@@ -76,8 +77,8 @@ namespace Kivii.Client.SampleInbounds
tbCurrentLocation.Text = ""; tbCurrentLocation.Text = "";
lbCurrentPackageStatus.Text = ""; lbCurrentPackageStatus.Text = "";
cbSetCurrentPackageOwner.DataSource = null; cbSetCurrentPackageOwner.DataSource = null;
cbSetCurrentPackageOwner.DisplayMember = "OwnerName"; cbSetCurrentPackageOwner.DisplayMember = "FullName";
cbSetCurrentPackageOwner.ValueMember = "OwnerKvid"; cbSetCurrentPackageOwner.ValueMember = "Kvid";
tbCurrentPackage.Text = ""; tbCurrentPackage.Text = "";
tbSetCurrentPackage.Text = ""; tbSetCurrentPackage.Text = "";
dgvSamples.DataSource = null; dgvSamples.DataSource = null;
...@@ -161,7 +162,7 @@ namespace Kivii.Client.SampleInbounds ...@@ -161,7 +162,7 @@ namespace Kivii.Client.SampleInbounds
#endregion #endregion
#region Reader Function #region Reader Function
private void connectReader() private bool connectReader()
{ {
reader = new Reader(); reader = new Reader();
currentSetting = new ReaderSetting(); currentSetting = new ReaderSetting();
...@@ -186,12 +187,13 @@ namespace Kivii.Client.SampleInbounds ...@@ -186,12 +187,13 @@ namespace Kivii.Client.SampleInbounds
{ {
isConnected = false; isConnected = false;
outputMessage("连接读写器失败,失败原因: " + exception); outputMessage("连接读写器失败,失败原因: " + exception);
return; return false;
} }
else else
{ {
isConnected = true; isConnected = true;
outputMessage($"当前连接: {Environment.NewLine}{defaultPort}@{defaultBaudrate}"); outputMessage($"当前连接: {Environment.NewLine}{defaultPort}@{defaultBaudrate}");
return true;
} }
} }
private void disConnectReader() private void disConnectReader()
...@@ -284,8 +286,44 @@ namespace Kivii.Client.SampleInbounds ...@@ -284,8 +286,44 @@ namespace Kivii.Client.SampleInbounds
_userInfo.PopulateWith(response); _userInfo.PopulateWith(response);
//tbCurrentPackageDepartment.Text = _userInfo.DepartmentName; //tbCurrentPackageDepartment.Text = _userInfo.DepartmentName;
initLocation(); initLocation();
initOrganizations();
} }
private void initOrganizations()
{
if (_client == null)
{
MessageBox.Show("请先登录!");
return;
}
var request = new OrganizationQuery();
var task = _client.PostAsync(request);
task.Success(resp =>
{
if (resp.Results.Count <= 0)
{
MessageBox.Show("未能获取所属部门信息!", "初始化实验室组");
return;
}
this.Invoke(new Action(delegate
{
cbSetCurrentPackageOwner.DataSource = null;
}));
_currentOrgs = resp.Results.ToList();
int indexWuli = _currentOrgs.FindIndex(o => o.FullName.Contains("物理"));
this.Invoke(new Action(delegate
{
cbSetCurrentPackageOwner.Enabled = true;
cbSetCurrentPackageOwner.DataSource = _currentOrgs;
if (indexWuli != -1) cbSetCurrentPackageOwner.SelectedIndex = indexWuli;
}));
});
task.Error(err =>
{
outputMessage(err.GetResponseStatus().Message);
});
}
private void initLocation() private void initLocation()
{ {
if (_client == null) if (_client == null)
...@@ -300,7 +338,7 @@ namespace Kivii.Client.SampleInbounds ...@@ -300,7 +338,7 @@ namespace Kivii.Client.SampleInbounds
} }
var request = new LocationQuery(); var request = new LocationQuery();
request.OwnerKvid = _userInfo.DepartmentKvid; request.OwnerKvid = _userInfo.DepartmentKvid;
request.OwnerKvid = Guid.Parse("5F344646-C9D2-413F-8DC6-500265C01CA2");//仓库 //request.OwnerKvid = Guid.Parse("5F344646-C9D2-413F-8DC6-500265C01CA2");//仓库
//request.OwnerKvid = Guid.Parse("D4CE47D2-5FC8-479D-A0CA-BACDF1A891BF");//色牢度组 //request.OwnerKvid = Guid.Parse("D4CE47D2-5FC8-479D-A0CA-BACDF1A891BF");//色牢度组
//request.OwnerKvid = Guid.Parse("9D026818-6E78-40F8-A715-2887F96F34DC");//纤检组 //request.OwnerKvid = Guid.Parse("9D026818-6E78-40F8-A715-2887F96F34DC");//纤检组
//request.OwnerKvid = Guid.Parse("208C24FB-1443-4B9E-9886-02ED3B9A8F45");//安全组 //request.OwnerKvid = Guid.Parse("208C24FB-1443-4B9E-9886-02ED3B9A8F45");//安全组
...@@ -319,6 +357,9 @@ namespace Kivii.Client.SampleInbounds ...@@ -319,6 +357,9 @@ namespace Kivii.Client.SampleInbounds
_currentLocation.PopulateWith(location); _currentLocation.PopulateWith(location);
tbSetCurrentPackage.Enabled = _currentLocation != null; tbSetCurrentPackage.Enabled = _currentLocation != null;
tbCurrentLocation.Text = _currentLocation.Address; tbCurrentLocation.Text = _currentLocation.Address;
btnScanRfid.Enabled = _currentLocation != null;
tbScanSample.Enabled = _currentLocation != null;
tbScanSample.Text = "";
}); });
task.Error(err => task.Error(err =>
{ {
...@@ -327,21 +368,51 @@ namespace Kivii.Client.SampleInbounds ...@@ -327,21 +368,51 @@ namespace Kivii.Client.SampleInbounds
MessageBox.Show(err.Message, "位置信息"); MessageBox.Show(err.Message, "位置信息");
}); });
} }
private void setCurrentPackage(Sample package)
{
_currentPackage = new Sample();
_currentPackage.PopulateWith(package);
tbSetCurrentPackage.Text = _currentPackage.Name;
tbSetCurrentPackage.Enabled = _currentPackage == null;
tbCurrentPackage.Text = _currentPackage.Name + (_currentPackage.PackageName.IsNullOrEmpty() ? "" : $"({_currentPackage.PackageName})");
btnClearCurrentPackage.Enabled = _currentPackage != null;
//cbSetCurrentPackageNode.Enabled = _currentPackage.Status == (int)PackageStatus.Empty || _currentPackage.Status == (int)PackageStatus.Full;
//btnScanRfid.Enabled = _currentPackage.Status == (int)PackageStatus.Full;
btnSampleAssign.Enabled = _currentPackage.Status == (int)PackageStatus.Full;
//tbScanSample.Enabled = _currentPackage.Status == (int)PackageStatus.Full;
//tbScanSample.Text = "";
if (_currentPackage.Status != (int)PackageStatus.Empty)
{
querySampleInPackaged();
}
if (_currentPackage.Status != (int)PackageStatus.Full)
{
lbCurrentPackageStatus.Text = _currentPackage.Status == (int)PackageStatus.Inbound ? "当前箱子已入库" : "当前箱子无样品";
outputMessage($"当前箱子为{(_currentPackage.Status == (int)PackageStatus.Inbound ? "已入库" : "空闲")}状态,无法继续操作!");
return;
}
Thread.Sleep(200);
if (!isConnected || reader == null)
{
btnScanRfid_Click(null, null);
}
}
private void searchPackage() private void searchPackage(string packageName = null, Guid? packageKvid = null)
{ {
if (_client == null) if (_client == null)
{ {
MessageBox.Show("请先登录!"); MessageBox.Show("请先登录!");
return; return;
} }
if (tbSetCurrentPackage.Text.IsNullOrEmpty()) if (packageName.IsNullOrEmpty() && (packageKvid == null || packageKvid == Guid.Empty))
{ {
MessageBox.Show("请输入箱号!"); MessageBox.Show("请输入箱号!");
return; return;
} }
var request = new SampleQuery(); var request = new SampleQuery();
request.Name = tbSetCurrentPackage.Text; if (!packageName.IsNullOrEmpty()) request.Name = packageName;
if (packageKvid != null && packageKvid != Guid.Empty) request.Kvid = packageKvid.Value;
request.Type = SampleType.Package; request.Type = SampleType.Package;
var task = _client.PostAsync(request); var task = _client.PostAsync(request);
task.Success(resp => task.Success(resp =>
...@@ -353,28 +424,7 @@ namespace Kivii.Client.SampleInbounds ...@@ -353,28 +424,7 @@ namespace Kivii.Client.SampleInbounds
return; return;
} }
var package = resp.Results.FirstOrDefault(); var package = resp.Results.FirstOrDefault();
_currentPackage = new Sample(); setCurrentPackage(package);
_currentPackage.PopulateWith(package);
tbSetCurrentPackage.Enabled = _currentPackage == null;
tbCurrentPackage.Text = _currentPackage.Name + (_currentPackage.PackageName.IsNullOrEmpty() ? "" : $"({_currentPackage.PackageName})");
btnClearCurrentPackage.Enabled = _currentPackage != null;
//cbSetCurrentPackageNode.Enabled = _currentPackage.Status == (int)PackageStatus.Empty || _currentPackage.Status == (int)PackageStatus.Full;
btnScanRfid.Enabled = _currentPackage.Status == (int)PackageStatus.Full;
btnSampleAssign.Enabled = _currentPackage.Status == (int)PackageStatus.Full;
tbScanSample.Enabled = _currentPackage.Status == (int)PackageStatus.Full;
tbScanSample.Text = "";
if (_currentPackage.Status != (int)PackageStatus.Empty)
{
querySampleInPackaged();
}
if (_currentPackage.Status != (int)PackageStatus.Full)
{
lbCurrentPackageStatus.Text = _currentPackage.Status == (int)PackageStatus.Inbound ? "当前箱子已入库" : "当前箱子无样品";
outputMessage($"当前箱子为{(_currentPackage.Status == (int)PackageStatus.Inbound ? "已入库" : "空闲")}状态,无法继续操作!");
return;
}
Thread.Sleep(200);
btnScanRfid_Click(null, null);
}); });
task.Error(err => task.Error(err =>
{ {
...@@ -412,19 +462,29 @@ namespace Kivii.Client.SampleInbounds ...@@ -412,19 +462,29 @@ namespace Kivii.Client.SampleInbounds
var task = _client.PostAsync(request); var task = _client.PostAsync(request);
task.Success(resp => task.Success(resp =>
{ {
int index = cbSetCurrentPackageOwner.SelectedIndex;
var owners = new List<Sample>(); if (resp.Results.Count > 0)
foreach (var item in resp.Results)
{ {
if (owners.Exists(o => o.OwnerKvid == item.OwnerKvid)) continue; var first = resp.Results[0];
owners.Add(item); if (!_currentOrgs.IsNullOrEmpty())
{
index = _currentOrgs.FindIndex(o => o.Kvid == first.OwnerKvid);
}
} }
_currentPackageSamples = resp.Results.ToList(); _currentPackageSamples = resp.Results.ToList();
if (!_currentScanSamples.IsNullOrEmpty())
{
foreach (var item in _currentPackageSamples)
{
if (_currentScanSamples.Exists(o => o.Kvid == item.Kvid))
{
item.IsMatched = true;
}
}
}
this.Invoke(new Action(delegate this.Invoke(new Action(delegate
{ {
cbSetCurrentPackageOwner.DataSource = owners; if (index != -1) cbSetCurrentPackageOwner.SelectedIndex = index;
cbSetCurrentPackageOwner.SelectedIndex = 0;
cbSetCurrentPackageOwner.Enabled = true;
dgvSamples.DataSource = _currentPackageSamples; dgvSamples.DataSource = _currentPackageSamples;
})); }));
outputMessage($"成功查询到箱号:{_currentPackage.Name}{_currentPackageSamples.Count}件样品!"); outputMessage($"成功查询到箱号:{_currentPackage.Name}{_currentPackageSamples.Count}件样品!");
...@@ -446,13 +506,13 @@ namespace Kivii.Client.SampleInbounds ...@@ -446,13 +506,13 @@ namespace Kivii.Client.SampleInbounds
{ {
request.BizKvid = epcKvid; request.BizKvid = epcKvid;
} }
var ownerSelected = cbSetCurrentPackageOwner.SelectedItem as Sample; var ownerSelected = cbSetCurrentPackageOwner.SelectedItem as Organization;
if (ownerSelected == null) if (ownerSelected == null)
{ {
outputMessage("请设置交接组部门信息!"); outputMessage("请设置交接组部门信息!");
return; return;
} }
request.OwnerKvid = ownerSelected.OwnerKvid; request.OwnerKvid = ownerSelected.Kvid;
try try
{ {
var resp = _client.Post(request); var resp = _client.Post(request);
...@@ -463,15 +523,38 @@ namespace Kivii.Client.SampleInbounds ...@@ -463,15 +523,38 @@ namespace Kivii.Client.SampleInbounds
return; return;
} }
var record = resp.Results[0]; var record = resp.Results[0];
if (_currentScanSamples == null) _currentScanSamples = new List<Sample>(); if (_currentPackage == null && record.PackageKvid != Guid.Empty)
if (!_currentScanSamples.Exists(o => o.Kvid == record.Kvid))
{ {
_currentScanSamples.Add(record); searchPackage(null, record.PackageKvid);
} }
this.Invoke(new Action(delegate this.Invoke(new Action(delegate
{ {
dgvRfidSamples.DataSource = null; dgvRfidSamples.DataSource = null;
})); }));
if (_currentScanSamples == null) _currentScanSamples = new List<Sample>();
if (!_currentPackageSamples.IsNullOrEmpty())
{
this.Invoke(new Action(delegate
{
dgvSamples.DataSource = null;
}));
foreach (var item in _currentPackageSamples)
{
if (item.Kvid == record.Kvid)
{
item.IsMatched = true;
record.IsMatched = true;
}
}
this.Invoke(new Action(delegate
{
dgvSamples.DataSource = _currentPackageSamples;
}));
}
if (!_currentScanSamples.Exists(o => o.Kvid == record.Kvid))
{
_currentScanSamples.Add(record);
}
this.Invoke(new Action(delegate this.Invoke(new Action(delegate
{ {
dgvRfidSamples.DataSource = _currentScanSamples; dgvRfidSamples.DataSource = _currentScanSamples;
...@@ -567,6 +650,7 @@ namespace Kivii.Client.SampleInbounds ...@@ -567,6 +650,7 @@ namespace Kivii.Client.SampleInbounds
if (samples.IsNullOrEmpty()) return; if (samples.IsNullOrEmpty()) return;
var kvids = new List<Guid>(); var kvids = new List<Guid>();
var unPackageKvids = new List<Guid>(); var unPackageKvids = new List<Guid>();
var notCurrentPackageKvids = new List<Guid>();
foreach (var sample in samples)//过滤重复交接的 foreach (var sample in samples)//过滤重复交接的
{ {
if (sample.PackageKvid == Guid.Empty)//扫描的样品并未在设置的包裹里 if (sample.PackageKvid == Guid.Empty)//扫描的样品并未在设置的包裹里
...@@ -574,6 +658,11 @@ namespace Kivii.Client.SampleInbounds ...@@ -574,6 +658,11 @@ namespace Kivii.Client.SampleInbounds
unPackageKvids.Add(sample.Kvid); unPackageKvids.Add(sample.Kvid);
continue; continue;
} }
if (sample.PackageKvid != _currentPackage.Kvid)
{
notCurrentPackageKvids.Add(sample.Kvid);
continue;
}
if (sample.CurrentLocation == null) if (sample.CurrentLocation == null)
{ {
this.Invoke(new Action(delegate this.Invoke(new Action(delegate
...@@ -612,7 +701,7 @@ namespace Kivii.Client.SampleInbounds ...@@ -612,7 +701,7 @@ namespace Kivii.Client.SampleInbounds
} }
if (!unPackageKvids.IsNullOrEmpty()) if (!unPackageKvids.IsNullOrEmpty())
{ {
samplePackaging(unPackageKvids); if (ckbAutoPackage.Checked) samplePackaging(unPackageKvids);
} }
} }
#endregion #endregion
...@@ -639,6 +728,7 @@ namespace Kivii.Client.SampleInbounds ...@@ -639,6 +728,7 @@ namespace Kivii.Client.SampleInbounds
//tbSetCurrentPackage.Enabled = !btnLogin.Enabled; //tbSetCurrentPackage.Enabled = !btnLogin.Enabled;
setDefault(tbxServiceUrl, tbxUserName, tbxPassword); setDefault(tbxServiceUrl, tbxUserName, tbxPassword);
outputMessage($"登录成功,登录人:{resp.DisplayName}", true); outputMessage($"登录成功,登录人:{resp.DisplayName}", true);
connectReader();
}, true); }, true);
task.Error(err => task.Error(err =>
{ {
...@@ -684,11 +774,12 @@ namespace Kivii.Client.SampleInbounds ...@@ -684,11 +774,12 @@ namespace Kivii.Client.SampleInbounds
} }
} }
private void tbSetCurrentPackage_KeyDown(object sender, KeyEventArgs e) private void tbSetCurrentPackage_KeyDown(object sender, KeyEventArgs e)
{ {
if (e.KeyCode == Keys.Enter) if (e.KeyCode == Keys.Enter)
{ {
searchPackage(); searchPackage(tbSetCurrentPackage.Text);
} }
} }
...@@ -700,15 +791,15 @@ namespace Kivii.Client.SampleInbounds ...@@ -700,15 +791,15 @@ namespace Kivii.Client.SampleInbounds
tbSetCurrentPackage.Enabled = true; tbSetCurrentPackage.Enabled = true;
tbCurrentPackage.Text = ""; tbCurrentPackage.Text = "";
btnClearCurrentPackage.Enabled = false; btnClearCurrentPackage.Enabled = false;
btnScanRfid.Enabled = false; //btnScanRfid.Enabled = false;
btnSampleAssign.Enabled = false; btnSampleAssign.Enabled = false;
tbScanSample.Enabled = false; //tbScanSample.Enabled = false;
tbScanSample.Text = ""; //tbScanSample.Text = "";
lbCurrentPackageStatus.Text = ""; lbCurrentPackageStatus.Text = "";
cbSetCurrentPackageOwner.DataSource = null; //cbSetCurrentPackageOwner.DataSource = null;
cbSetCurrentPackageOwner.DisplayMember = "OwnerName"; //cbSetCurrentPackageOwner.DisplayMember = "OwnerName";
cbSetCurrentPackageOwner.ValueMember = "OwnerKvid"; //cbSetCurrentPackageOwner.ValueMember = "OwnerKvid";
cbSetCurrentPackageOwner.Enabled = false; //cbSetCurrentPackageOwner.Enabled = false;
dgvSamples.DataSource = null; dgvSamples.DataSource = null;
dgvRfidSamples.DataSource = null; dgvRfidSamples.DataSource = null;
btnRealTimeInventory_Stop(); btnRealTimeInventory_Stop();
...@@ -749,8 +840,8 @@ namespace Kivii.Client.SampleInbounds ...@@ -749,8 +840,8 @@ namespace Kivii.Client.SampleInbounds
private void cbSetCurrentPackageOwner_SelectedValueChanged(object sender, EventArgs e) private void cbSetCurrentPackageOwner_SelectedValueChanged(object sender, EventArgs e)
{ {
var selected = cbSetCurrentPackageOwner.SelectedItem as Sample; var selected = cbSetCurrentPackageOwner.SelectedItem as Organization;
if (selected != null) outputMessage($"当前设置交接组:{selected.OwnerName}!"); if (selected != null) outputMessage($"当前设置交接组:{selected.FullName}!");
} }
private void tbScanSample_KeyDown(object sender, KeyEventArgs e) private void tbScanSample_KeyDown(object sender, KeyEventArgs e)
...@@ -767,33 +858,37 @@ namespace Kivii.Client.SampleInbounds ...@@ -767,33 +858,37 @@ namespace Kivii.Client.SampleInbounds
MessageBox.Show("未获取当前位置."); MessageBox.Show("未获取当前位置.");
return; return;
} }
if (_currentPackage == null) //if (_currentPackage == null)
{ //{
MessageBox.Show("未获取当前箱号."); // MessageBox.Show("未获取当前箱号.");
return; // return;
} //}
if (_currentPackage.Status != (int)PackageStatus.Full) //if (_currentPackage.Status != (int)PackageStatus.Full)
{ //{
outputMessage($"当前箱子为{(_currentPackage.Status == (int)PackageStatus.Inbound ? "已入库" : "空闲")}状态,无法继续操作!"); // outputMessage($"当前箱子为{(_currentPackage.Status == (int)PackageStatus.Inbound ? "已入库" : "空闲")}状态,无法继续操作!");
return; // return;
} //}
samplePreAssigning(null, null, tbScanSample.Text); samplePreAssigning(null, null, tbScanSample.Text);
} }
} }
private void btnScanRfid_Click(object sender, EventArgs e) private void btnScanRfid_Click(object sender, EventArgs e)
{ {
if (!isConnected || reader == null)
{
MessageBox.Show("读写器未连接,请先连接读写器!");
return;
}
//reader.ReadTag(currentSetting.btReadId, 2, 0, 8);
//if (!isConnected || reader == null) //if (!isConnected || reader == null)
//{ //{
// connectReader(); // MessageBox.Show("读写器未连接,请先连接读写器!");
// Thread.Sleep(1000); // return;
//} //}
//reader.ReadTag(currentSetting.btReadId, 2, 0, 8);
if (!isConnected || reader == null)
{
if (!connectReader())
{
MessageBox.Show("读写器未连接,请查看是否读写器设备!");
return;
}
Thread.Sleep(1000);
}
if (currentInventoryBuffer.bLoopInventory) if (currentInventoryBuffer.bLoopInventory)
{ {
btnRealTimeInventory_Stop(); btnRealTimeInventory_Stop();
...@@ -810,5 +905,27 @@ namespace Kivii.Client.SampleInbounds ...@@ -810,5 +905,27 @@ namespace Kivii.Client.SampleInbounds
var assignSamples = _currentScanSamples.ToList();//new一个list不影响原来的数组 var assignSamples = _currentScanSamples.ToList();//new一个list不影响原来的数组
preSampleAssigning(assignSamples); preSampleAssigning(assignSamples);
} }
private void dgvSamples_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
{
e.Row.Selected = false;
}
private void dgvRfidSamples_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
{
e.Row.Selected = false;
}
private void dgvSamples_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
for (int i = 0; i < dgvSamples.Rows.Count; i++)
{
var item = dgvSamples.Rows[i].DataBoundItem as Sample;
if (item.IsMatched)
{
dgvSamples.Rows[i].DefaultCellStyle.BackColor = Color.Green;
}
}
}
} }
} }
...@@ -19,7 +19,7 @@ namespace Kivii.Samples.Transforms ...@@ -19,7 +19,7 @@ namespace Kivii.Samples.Transforms
public string Name { get; set; } public string Name { get; set; }
public SampleType Type { get; set; } public SampleType Type { get; set; }
//public Guid PackageKvid { get; set; } public Guid? Kvid { get; set; }
} }
[Route(Configs.RouteSampleQuery)] [Route(Configs.RouteSampleQuery)]
...@@ -60,4 +60,11 @@ namespace Kivii.Samples.Transforms ...@@ -60,4 +60,11 @@ namespace Kivii.Samples.Transforms
public Guid Kvid { get; set; }//要流转样品信息 public Guid Kvid { get; set; }//要流转样品信息
public Location Location { get; set; }//地点位置信息,只需要InternalCode public Location Location { get; set; }//地点位置信息,只需要InternalCode
} }
[Route(Configs.RouteOrganizationQuery)]
public class OrganizationQuery : IReturn<RestfulQueryResponse<Organization>>
{
public string InternalCodeContains { get; set; } = "ChildGroup";
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment