Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
Kivii.Client.SampleInbounds.V4.0
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陶然
Kivii.Client.SampleInbounds.V4.0
Commits
edc4854e
Commit
edc4854e
authored
May 30, 2023
by
陶然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
0f2fab40
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
338 additions
and
90 deletions
+338
-90
Configs.cs
Src/Configs.cs
+1
-0
Sample.Entities.cs
Src/Entities/Sample.Entities.cs
+107
-0
FrmMain.Designer.cs
Src/FrmMain.Designer.cs
+32
-16
FrmMain.cs
Src/FrmMain.cs
+190
-73
RestfulRequests.cs
Src/Requests/RestfulRequests.cs
+8
-1
No files found.
Src/Configs.cs
View file @
edc4854e
...
...
@@ -17,6 +17,7 @@ namespace Kivii.Client
public
const
string
RouteSampleAssign
=
"/Restful/Kivii.Samples.Entities.Sample/Assign"
;
public
const
string
RouteSamplePackaging
=
"/Restful/Kivii.Samples.Entities.Sample/Packaging"
;
public
const
string
RouteSampleUnPackaging
=
"/Restful/Kivii.Samples.Entities.Sample/UnPackaging"
;
public
const
string
RouteOrganizationQuery
=
"/Restful/Kivii.Organizations.Entities.Organization/Query"
;
}
}
Src/Entities/Sample.Entities.cs
View file @
edc4854e
...
...
@@ -232,6 +232,9 @@ namespace Kivii.Samples.Entities
[
Ignore
]
public
Sample
CurrentPackage
{
get
;
set
;
}
[
Ignore
]
public
bool
IsMatched
{
get
;
set
;
}
#
region
创建
/
更新人
V1
.
0
[
ApiMember
(
Description
=
"创建人Kvid "
)]
[
IgnoreUpdate
]
...
...
@@ -473,4 +476,108 @@ namespace Kivii.Samples.Entities
/// </summary>
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
}
}
Src/FrmMain.Designer.cs
View file @
edc4854e
...
...
@@ -78,6 +78,7 @@
this
.
btnClearCurrentPackage
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
lbSetPackage
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
tbSetCurrentPackage
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
ckbAutoPackage
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
plLeft
.
SuspendLayout
();
this
.
gbInfo
.
SuspendLayout
();
this
.
gbLogin
.
SuspendLayout
();
...
...
@@ -98,7 +99,7 @@
this
.
plLeft
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Left
;
this
.
plLeft
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
plLeft
.
Name
=
"plLeft"
;
this
.
plLeft
.
Size
=
new
System
.
Drawing
.
Size
(
252
,
6
67
);
this
.
plLeft
.
Size
=
new
System
.
Drawing
.
Size
(
252
,
6
59
);
this
.
plLeft
.
TabIndex
=
0
;
//
// gbInfo
...
...
@@ -107,7 +108,7 @@
this
.
gbInfo
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
gbInfo
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
447
);
this
.
gbInfo
.
Name
=
"gbInfo"
;
this
.
gbInfo
.
Size
=
new
System
.
Drawing
.
Size
(
252
,
2
20
);
this
.
gbInfo
.
Size
=
new
System
.
Drawing
.
Size
(
252
,
2
12
);
this
.
gbInfo
.
TabIndex
=
2
;
this
.
gbInfo
.
TabStop
=
false
;
this
.
gbInfo
.
Text
=
"信息"
;
...
...
@@ -117,7 +118,7 @@
this
.
rtbMessage
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
rtbMessage
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
17
);
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
.
Text
=
""
;
//
...
...
@@ -294,9 +295,9 @@
this
.
plRight
.
Controls
.
Add
(
this
.
gbRfid
);
this
.
plRight
.
Controls
.
Add
(
this
.
gbRightToolBar
);
this
.
plRight
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Right
;
this
.
plRight
.
Location
=
new
System
.
Drawing
.
Point
(
6
59
,
0
);
this
.
plRight
.
Location
=
new
System
.
Drawing
.
Point
(
6
35
,
0
);
this
.
plRight
.
Name
=
"plRight"
;
this
.
plRight
.
Size
=
new
System
.
Drawing
.
Size
(
4
29
,
667
);
this
.
plRight
.
Size
=
new
System
.
Drawing
.
Size
(
4
50
,
659
);
this
.
plRight
.
TabIndex
=
1
;
//
// gbRfid
...
...
@@ -305,7 +306,7 @@
this
.
gbRfid
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
gbRfid
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
125
);
this
.
gbRfid
.
Name
=
"gbRfid"
;
this
.
gbRfid
.
Size
=
new
System
.
Drawing
.
Size
(
4
29
,
542
);
this
.
gbRfid
.
Size
=
new
System
.
Drawing
.
Size
(
4
50
,
534
);
this
.
gbRfid
.
TabIndex
=
2
;
this
.
gbRfid
.
TabStop
=
false
;
this
.
gbRfid
.
Text
=
"Rfid扫描结果"
;
...
...
@@ -328,9 +329,10 @@
this
.
dgvRfidSamples
.
Name
=
"dgvRfidSamples"
;
this
.
dgvRfidSamples
.
ReadOnly
=
true
;
this
.
dgvRfidSamples
.
RowTemplate
.
Height
=
23
;
this
.
dgvRfidSamples
.
Size
=
new
System
.
Drawing
.
Size
(
4
23
,
522
);
this
.
dgvRfidSamples
.
Size
=
new
System
.
Drawing
.
Size
(
4
44
,
514
);
this
.
dgvRfidSamples
.
TabIndex
=
0
;
this
.
dgvRfidSamples
.
RowPostPaint
+=
new
System
.
Windows
.
Forms
.
DataGridViewRowPostPaintEventHandler
(
this
.
dgvRfidSamples_RowPostPaint
);
this
.
dgvRfidSamples
.
RowStateChanged
+=
new
System
.
Windows
.
Forms
.
DataGridViewRowStateChangedEventHandler
(
this
.
dgvRfidSamples_RowStateChanged
);
//
// dataGridViewTextBoxColumn1
//
...
...
@@ -394,6 +396,7 @@
//
// gbRightToolBar
//
this
.
gbRightToolBar
.
Controls
.
Add
(
this
.
ckbAutoPackage
);
this
.
gbRightToolBar
.
Controls
.
Add
(
this
.
btnSampleAssign
);
this
.
gbRightToolBar
.
Controls
.
Add
(
this
.
lbTips
);
this
.
gbRightToolBar
.
Controls
.
Add
(
this
.
lbScanSample
);
...
...
@@ -402,7 +405,7 @@
this
.
gbRightToolBar
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Top
;
this
.
gbRightToolBar
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
gbRightToolBar
.
Name
=
"gbRightToolBar"
;
this
.
gbRightToolBar
.
Size
=
new
System
.
Drawing
.
Size
(
4
29
,
125
);
this
.
gbRightToolBar
.
Size
=
new
System
.
Drawing
.
Size
(
4
50
,
125
);
this
.
gbRightToolBar
.
TabIndex
=
1
;
this
.
gbRightToolBar
.
TabStop
=
false
;
this
.
gbRightToolBar
.
Text
=
"操作台"
;
...
...
@@ -413,7 +416,7 @@
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
.
ForeColor
=
System
.
Drawing
.
Color
.
DarkBlue
;
this
.
btnSampleAssign
.
Location
=
new
System
.
Drawing
.
Point
(
3
13
,
17
);
this
.
btnSampleAssign
.
Location
=
new
System
.
Drawing
.
Point
(
3
34
,
17
);
this
.
btnSampleAssign
.
Name
=
"btnSampleAssign"
;
this
.
btnSampleAssign
.
Size
=
new
System
.
Drawing
.
Size
(
113
,
105
);
this
.
btnSampleAssign
.
TabIndex
=
84
;
...
...
@@ -448,7 +451,7 @@
this
.
tbScanSample
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
18F
);
this
.
tbScanSample
.
Location
=
new
System
.
Drawing
.
Point
(
7
,
44
);
this
.
tbScanSample
.
Name
=
"tbScanSample"
;
this
.
tbScanSample
.
Size
=
new
System
.
Drawing
.
Size
(
2
09
,
35
);
this
.
tbScanSample
.
Size
=
new
System
.
Drawing
.
Size
(
2
24
,
35
);
this
.
tbScanSample
.
TabIndex
=
81
;
this
.
tbScanSample
.
KeyDown
+=
new
System
.
Windows
.
Forms
.
KeyEventHandler
(
this
.
tbScanSample_KeyDown
);
//
...
...
@@ -459,7 +462,7 @@
this
.
btnScanRfid
.
ForeColor
=
System
.
Drawing
.
Color
.
Chocolate
;
this
.
btnScanRfid
.
Location
=
new
System
.
Drawing
.
Point
(
7
,
82
);
this
.
btnScanRfid
.
Name
=
"btnScanRfid"
;
this
.
btnScanRfid
.
Size
=
new
System
.
Drawing
.
Size
(
2
09
,
40
);
this
.
btnScanRfid
.
Size
=
new
System
.
Drawing
.
Size
(
2
24
,
40
);
this
.
btnScanRfid
.
TabIndex
=
77
;
this
.
btnScanRfid
.
Text
=
"开始扫描"
;
this
.
btnScanRfid
.
UseVisualStyleBackColor
=
false
;
...
...
@@ -472,7 +475,7 @@
this
.
plMain
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
plMain
.
Location
=
new
System
.
Drawing
.
Point
(
252
,
0
);
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
;
//
// gbMain
...
...
@@ -481,7 +484,7 @@
this
.
gbMain
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
gbMain
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
125
);
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
.
TabStop
=
false
;
this
.
gbMain
.
Text
=
"箱内样品"
;
...
...
@@ -504,9 +507,11 @@
this
.
dgvSamples
.
Name
=
"dgvSamples"
;
this
.
dgvSamples
.
ReadOnly
=
true
;
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
.
DataBindingComplete
+=
new
System
.
Windows
.
Forms
.
DataGridViewBindingCompleteEventHandler
(
this
.
dgvSamples_DataBindingComplete
);
this
.
dgvSamples
.
RowPostPaint
+=
new
System
.
Windows
.
Forms
.
DataGridViewRowPostPaintEventHandler
(
this
.
dgvSamples_RowPostPaint
);
this
.
dgvSamples
.
RowStateChanged
+=
new
System
.
Windows
.
Forms
.
DataGridViewRowStateChangedEventHandler
(
this
.
dgvSamples_RowStateChanged
);
//
// SampleBizId
//
...
...
@@ -577,7 +582,7 @@
this
.
gbMainToolBar
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Top
;
this
.
gbMainToolBar
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
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
.
TabStop
=
false
;
this
.
gbMainToolBar
.
Text
=
"操作台"
;
...
...
@@ -622,11 +627,21 @@
this
.
tbSetCurrentPackage
.
TabIndex
=
78
;
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
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
108
8
,
667
);
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
108
5
,
659
);
this
.
Controls
.
Add
(
this
.
plMain
);
this
.
Controls
.
Add
(
this
.
plRight
);
this
.
Controls
.
Add
(
this
.
plLeft
);
...
...
@@ -703,6 +718,7 @@
private
System
.
Windows
.
Forms
.
ComboBox
cbSetCurrentPackageOwner
;
private
System
.
Windows
.
Forms
.
Label
lbCurrentPackageStatus
;
private
System
.
Windows
.
Forms
.
Button
btnSampleAssign
;
private
System
.
Windows
.
Forms
.
CheckBox
ckbAutoPackage
;
}
}
Src/FrmMain.cs
View file @
edc4854e
...
...
@@ -11,6 +11,7 @@ using System.ComponentModel;
using
System.Data
;
using
System.Drawing
;
using
System.Linq
;
using
System.Reflection
;
using
System.Text
;
using
System.Threading
;
using
System.Windows.Forms
;
...
...
@@ -25,12 +26,13 @@ namespace Kivii.Client.SampleInbounds
private
Sample
_currentPackage
;
private
List
<
Sample
>
_currentPackageSamples
;
private
List
<
Sample
>
_currentScanSamples
;
private
List
<
Organization
>
_currentOrgs
;
private
AuthenticateResponse
_userInfo
;
private
Reader
reader
;
private
ReaderSetting
currentSetting
;
private
InventoryBuffer
currentInventoryBuffer
;
private
string
defaultPort
=
"COM
2
"
;
private
string
defaultPort
=
"COM
1
"
;
private
int
defaultBaudrate
=
115200
;
private
bool
isConnected
=
false
;
...
...
@@ -46,7 +48,6 @@ namespace Kivii.Client.SampleInbounds
private
void
FrmMain_Load
(
object
sender
,
EventArgs
e
)
{
connectReader
();
initControls
();
loadDefault
(
tbxServiceUrl
,
tbxUserName
,
tbxPassword
);
}
...
...
@@ -76,8 +77,8 @@ namespace Kivii.Client.SampleInbounds
tbCurrentLocation
.
Text
=
""
;
lbCurrentPackageStatus
.
Text
=
""
;
cbSetCurrentPackageOwner
.
DataSource
=
null
;
cbSetCurrentPackageOwner
.
DisplayMember
=
"
Owner
Name"
;
cbSetCurrentPackageOwner
.
ValueMember
=
"
Owner
Kvid"
;
cbSetCurrentPackageOwner
.
DisplayMember
=
"
Full
Name"
;
cbSetCurrentPackageOwner
.
ValueMember
=
"Kvid"
;
tbCurrentPackage
.
Text
=
""
;
tbSetCurrentPackage
.
Text
=
""
;
dgvSamples
.
DataSource
=
null
;
...
...
@@ -161,7 +162,7 @@ namespace Kivii.Client.SampleInbounds
#
endregion
#
region
Reader
Function
private
void
connectReader
()
private
bool
connectReader
()
{
reader
=
new
Reader
();
currentSetting
=
new
ReaderSetting
();
...
...
@@ -186,12 +187,13 @@ namespace Kivii.Client.SampleInbounds
{
isConnected
=
false
;
outputMessage
(
"连接读写器失败,失败原因: "
+
exception
);
return
;
return
false
;
}
else
{
isConnected
=
true
;
outputMessage
(
$"当前连接:
{
Environment
.
NewLine
}{
defaultPort
}
@
{
defaultBaudrate
}
"
);
return
true
;
}
}
private
void
disConnectReader
()
...
...
@@ -284,8 +286,44 @@ namespace Kivii.Client.SampleInbounds
_userInfo
.
PopulateWith
(
response
);
//tbCurrentPackageDepartment.Text = _userInfo.DepartmentName;
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
()
{
if
(
_client
==
null
)
...
...
@@ -300,7 +338,7 @@ namespace Kivii.Client.SampleInbounds
}
var
request
=
new
LocationQuery
();
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("9D026818-6E78-40F8-A715-2887F96F34DC");//纤检组
//request.OwnerKvid = Guid.Parse("208C24FB-1443-4B9E-9886-02ED3B9A8F45");//安全组
...
...
@@ -319,6 +357,9 @@ namespace Kivii.Client.SampleInbounds
_currentLocation
.
PopulateWith
(
location
);
tbSetCurrentPackage
.
Enabled
=
_currentLocation
!=
null
;
tbCurrentLocation
.
Text
=
_currentLocation
.
Address
;
btnScanRfid
.
Enabled
=
_currentLocation
!=
null
;
tbScanSample
.
Enabled
=
_currentLocation
!=
null
;
tbScanSample
.
Text
=
""
;
});
task
.
Error
(
err
=>
{
...
...
@@ -327,21 +368,51 @@ namespace Kivii.Client.SampleInbounds
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
)
{
MessageBox
.
Show
(
"请先登录!"
);
return
;
}
if
(
tbSetCurrentPackage
.
Text
.
IsNullOrEmpty
(
))
if
(
packageName
.
IsNullOrEmpty
()
&&
(
packageKvid
==
null
||
packageKvid
==
Guid
.
Empty
))
{
MessageBox
.
Show
(
"请输入箱号!"
);
return
;
}
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
;
var
task
=
_client
.
PostAsync
(
request
);
task
.
Success
(
resp
=>
...
...
@@ -353,28 +424,7 @@ namespace Kivii.Client.SampleInbounds
return
;
}
var
package
=
resp
.
Results
.
FirstOrDefault
();
_currentPackage
=
new
Sample
();
_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
);
setCurrentPackage
(
package
);
});
task
.
Error
(
err
=>
{
...
...
@@ -412,19 +462,29 @@ namespace Kivii.Client.SampleInbounds
var
task
=
_client
.
PostAsync
(
request
);
task
.
Success
(
resp
=>
{
var
owners
=
new
List
<
Sample
>();
foreach
(
var
item
in
resp
.
Results
)
int
index
=
cbSetCurrentPackageOwner
.
SelectedIndex
;
if
(
resp
.
Results
.
Count
>
0
)
{
var
first
=
resp
.
Results
[
0
];
if
(!
_currentOrgs
.
IsNullOrEmpty
())
{
if
(
owners
.
Exists
(
o
=>
o
.
OwnerKvid
==
item
.
OwnerKvid
))
continue
;
owners
.
Add
(
item
);
index
=
_currentOrgs
.
FindIndex
(
o
=>
o
.
Kvid
==
first
.
OwnerKvid
)
;
}
}
_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
{
cbSetCurrentPackageOwner
.
DataSource
=
owners
;
cbSetCurrentPackageOwner
.
SelectedIndex
=
0
;
cbSetCurrentPackageOwner
.
Enabled
=
true
;
if
(
index
!=
-
1
)
cbSetCurrentPackageOwner
.
SelectedIndex
=
index
;
dgvSamples
.
DataSource
=
_currentPackageSamples
;
}));
outputMessage
(
$"成功查询到箱号:
{
_currentPackage
.
Name
}
中
{
_currentPackageSamples
.
Count
}
件样品!"
);
...
...
@@ -446,13 +506,13 @@ namespace Kivii.Client.SampleInbounds
{
request
.
BizKvid
=
epcKvid
;
}
var
ownerSelected
=
cbSetCurrentPackageOwner
.
SelectedItem
as
Sample
;
var
ownerSelected
=
cbSetCurrentPackageOwner
.
SelectedItem
as
Organization
;
if
(
ownerSelected
==
null
)
{
outputMessage
(
"请设置交接组部门信息!"
);
return
;
}
request
.
OwnerKvid
=
ownerSelected
.
Owner
Kvid
;
request
.
OwnerKvid
=
ownerSelected
.
Kvid
;
try
{
var
resp
=
_client
.
Post
(
request
);
...
...
@@ -463,15 +523,38 @@ namespace Kivii.Client.SampleInbounds
return
;
}
var
record
=
resp
.
Results
[
0
];
if
(
_currentScanSamples
==
null
)
_currentScanSamples
=
new
List
<
Sample
>();
if
(!
_currentScanSamples
.
Exists
(
o
=>
o
.
Kvid
==
record
.
Kvid
))
if
(
_currentPackage
==
null
&&
record
.
PackageKvid
!=
Guid
.
Empty
)
{
_currentScanSamples
.
Add
(
recor
d
);
searchPackage
(
null
,
record
.
PackageKvi
d
);
}
this
.
Invoke
(
new
Action
(
delegate
{
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
{
dgvRfidSamples
.
DataSource
=
_currentScanSamples
;
...
...
@@ -567,6 +650,7 @@ namespace Kivii.Client.SampleInbounds
if
(
samples
.
IsNullOrEmpty
())
return
;
var
kvids
=
new
List
<
Guid
>();
var
unPackageKvids
=
new
List
<
Guid
>();
var
notCurrentPackageKvids
=
new
List
<
Guid
>();
foreach
(
var
sample
in
samples
)
//过滤重复交接的
{
if
(
sample
.
PackageKvid
==
Guid
.
Empty
)
//扫描的样品并未在设置的包裹里
...
...
@@ -574,6 +658,11 @@ namespace Kivii.Client.SampleInbounds
unPackageKvids
.
Add
(
sample
.
Kvid
);
continue
;
}
if
(
sample
.
PackageKvid
!=
_currentPackage
.
Kvid
)
{
notCurrentPackageKvids
.
Add
(
sample
.
Kvid
);
continue
;
}
if
(
sample
.
CurrentLocation
==
null
)
{
this
.
Invoke
(
new
Action
(
delegate
...
...
@@ -612,7 +701,7 @@ namespace Kivii.Client.SampleInbounds
}
if
(!
unPackageKvids
.
IsNullOrEmpty
())
{
samplePackaging
(
unPackageKvids
);
if
(
ckbAutoPackage
.
Checked
)
samplePackaging
(
unPackageKvids
);
}
}
#
endregion
...
...
@@ -639,6 +728,7 @@ namespace Kivii.Client.SampleInbounds
//tbSetCurrentPackage.Enabled = !btnLogin.Enabled;
setDefault
(
tbxServiceUrl
,
tbxUserName
,
tbxPassword
);
outputMessage
(
$"登录成功,登录人:
{
resp
.
DisplayName
}
"
,
true
);
connectReader
();
},
true
);
task
.
Error
(
err
=>
{
...
...
@@ -684,11 +774,12 @@ namespace Kivii.Client.SampleInbounds
}
}
private
void
tbSetCurrentPackage_KeyDown
(
object
sender
,
KeyEventArgs
e
)
{
if
(
e
.
KeyCode
==
Keys
.
Enter
)
{
searchPackage
();
searchPackage
(
tbSetCurrentPackage
.
Text
);
}
}
...
...
@@ -700,15 +791,15 @@ namespace Kivii.Client.SampleInbounds
tbSetCurrentPackage
.
Enabled
=
true
;
tbCurrentPackage
.
Text
=
""
;
btnClearCurrentPackage
.
Enabled
=
false
;
btnScanRfid
.
Enabled
=
false
;
//
btnScanRfid.Enabled = false;
btnSampleAssign
.
Enabled
=
false
;
tbScanSample
.
Enabled
=
false
;
tbScanSample
.
Text
=
""
;
//
tbScanSample.Enabled = false;
//
tbScanSample.Text = "";
lbCurrentPackageStatus
.
Text
=
""
;
cbSetCurrentPackageOwner
.
DataSource
=
null
;
cbSetCurrentPackageOwner
.
DisplayMember
=
"OwnerName"
;
cbSetCurrentPackageOwner
.
ValueMember
=
"OwnerKvid"
;
cbSetCurrentPackageOwner
.
Enabled
=
false
;
//
cbSetCurrentPackageOwner.DataSource = null;
//
cbSetCurrentPackageOwner.DisplayMember = "OwnerName";
//
cbSetCurrentPackageOwner.ValueMember = "OwnerKvid";
//
cbSetCurrentPackageOwner.Enabled = false;
dgvSamples
.
DataSource
=
null
;
dgvRfidSamples
.
DataSource
=
null
;
btnRealTimeInventory_Stop
();
...
...
@@ -749,8 +840,8 @@ namespace Kivii.Client.SampleInbounds
private
void
cbSetCurrentPackageOwner_SelectedValueChanged
(
object
sender
,
EventArgs
e
)
{
var
selected
=
cbSetCurrentPackageOwner
.
SelectedItem
as
Sample
;
if
(
selected
!=
null
)
outputMessage
(
$"当前设置交接组:
{
selected
.
Owner
Name
}
!"
);
var
selected
=
cbSetCurrentPackageOwner
.
SelectedItem
as
Organization
;
if
(
selected
!=
null
)
outputMessage
(
$"当前设置交接组:
{
selected
.
Full
Name
}
!"
);
}
private
void
tbScanSample_KeyDown
(
object
sender
,
KeyEventArgs
e
)
...
...
@@ -767,33 +858,37 @@ namespace Kivii.Client.SampleInbounds
MessageBox
.
Show
(
"未获取当前位置."
);
return
;
}
if
(
_currentPackage
==
null
)
{
MessageBox
.
Show
(
"未获取当前箱号."
);
return
;
}
if
(
_currentPackage
.
Status
!=
(
int
)
PackageStatus
.
Full
)
{
outputMessage
(
$"当前箱子为
{(
_currentPackage
.
Status
==
(
int
)
PackageStatus
.
Inbound
?
"已入库"
:
"空闲"
)}
状态,无法继续操作!"
);
return
;
}
//
if (_currentPackage == null)
//
{
//
MessageBox.Show("未获取当前箱号.");
//
return;
//
}
//
if (_currentPackage.Status != (int)PackageStatus.Full)
//
{
//
outputMessage($"当前箱子为{(_currentPackage.Status == (int)PackageStatus.Inbound ? "已入库" : "空闲")}状态,无法继续操作!");
//
return;
//
}
samplePreAssigning
(
null
,
null
,
tbScanSample
.
Text
);
}
}
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
)
{
MessageBox
.
Show
(
"读写器未连接,请先连接读写器!"
);
if
(!
connectReader
())
{
MessageBox
.
Show
(
"读写器未连接,请查看是否读写器设备!"
);
return
;
}
//reader.ReadTag(currentSetting.btReadId, 2, 0, 8);
//if (!isConnected || reader == null)
//{
// connectReader();
// Thread.Sleep(1000);
//}
Thread
.
Sleep
(
1000
);
}
if
(
currentInventoryBuffer
.
bLoopInventory
)
{
btnRealTimeInventory_Stop
();
...
...
@@ -810,5 +905,27 @@ namespace Kivii.Client.SampleInbounds
var
assignSamples
=
_currentScanSamples
.
ToList
();
//new一个list不影响原来的数组
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
;
}
}
}
}
}
Src/Requests/RestfulRequests.cs
View file @
edc4854e
...
...
@@ -19,7 +19,7 @@ namespace Kivii.Samples.Transforms
public
string
Name
{
get
;
set
;
}
public
SampleType
Type
{
get
;
set
;
}
//public Guid Package
Kvid { get; set; }
public
Guid
?
Kvid
{
get
;
set
;
}
}
[
Route
(
Configs
.
RouteSampleQuery
)]
...
...
@@ -60,4 +60,11 @@ namespace Kivii.Samples.Transforms
public
Guid
Kvid
{
get
;
set
;
}
//要流转样品信息
public
Location
Location
{
get
;
set
;
}
//地点位置信息,只需要InternalCode
}
[
Route
(
Configs
.
RouteOrganizationQuery
)]
public
class
OrganizationQuery
:
IReturn
<
RestfulQueryResponse
<
Organization
>>
{
public
string
InternalCodeContains
{
get
;
set
;
}
=
"ChildGroup"
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment