Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张东亮
/
NS200
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
图表
网络
创建新的问题
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit b237d193
由
刘韬
编写于
2026-02-26 15:46:18 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
SO1340 定制添加删除含有NA字样的条码
1 个父辈
9a16b822
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
54 行增加
和
34 行删除
AutoScanAndLabel/AboutBox1.Designer.cs
AutoScanAndLabel/AboutBox1.cs
AutoScanAndLabel/Program.cs
AutoScanAndLabel/Properties/AssemblyInfo.cs
Common/Setting_Init.cs
DeviceLibrary/DeviceLibrary/CodeManager.cs
AutoScanAndLabel/AboutBox1.Designer.cs
查看文件 @
b237d19
...
@@ -43,9 +43,9 @@ namespace AutoScanAndLabel
...
@@ -43,9 +43,9 @@ namespace AutoScanAndLabel
this
.
tableLayoutPanel
.
ColumnCount
=
2
;
this
.
tableLayoutPanel
.
ColumnCount
=
2
;
this
.
tableLayoutPanel
.
ColumnStyles
.
Add
(
new
System
.
Windows
.
Forms
.
ColumnStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Percent
,
12.98701F
));
this
.
tableLayoutPanel
.
ColumnStyles
.
Add
(
new
System
.
Windows
.
Forms
.
ColumnStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Percent
,
12.98701F
));
this
.
tableLayoutPanel
.
ColumnStyles
.
Add
(
new
System
.
Windows
.
Forms
.
ColumnStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Percent
,
87.01299F
));
this
.
tableLayoutPanel
.
ColumnStyles
.
Add
(
new
System
.
Windows
.
Forms
.
ColumnStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Percent
,
87.01299F
));
this
.
tableLayoutPanel
.
Controls
.
Add
(
this
.
labelCopyright
,
1
,
2
);
this
.
tableLayoutPanel
.
Controls
.
Add
(
this
.
labelProductName
,
1
,
0
);
this
.
tableLayoutPanel
.
Controls
.
Add
(
this
.
labelProductName
,
1
,
0
);
this
.
tableLayoutPanel
.
Controls
.
Add
(
this
.
labelVersion
,
1
,
1
);
this
.
tableLayoutPanel
.
Controls
.
Add
(
this
.
labelVersion
,
1
,
1
);
this
.
tableLayoutPanel
.
Controls
.
Add
(
this
.
labelCopyright
,
1
,
2
);
this
.
tableLayoutPanel
.
Controls
.
Add
(
this
.
labelCompanyName
,
1
,
3
);
this
.
tableLayoutPanel
.
Controls
.
Add
(
this
.
labelCompanyName
,
1
,
3
);
this
.
tableLayoutPanel
.
Controls
.
Add
(
this
.
textBoxDescription
,
1
,
4
);
this
.
tableLayoutPanel
.
Controls
.
Add
(
this
.
textBoxDescription
,
1
,
4
);
this
.
tableLayoutPanel
.
Controls
.
Add
(
this
.
okButton
,
1
,
5
);
this
.
tableLayoutPanel
.
Controls
.
Add
(
this
.
okButton
,
1
,
5
);
...
@@ -97,6 +97,7 @@ namespace AutoScanAndLabel
...
@@ -97,6 +97,7 @@ namespace AutoScanAndLabel
this
.
labelCopyright
.
Name
=
"labelCopyright"
;
this
.
labelCopyright
.
Name
=
"labelCopyright"
;
this
.
labelCopyright
.
Size
=
new
System
.
Drawing
.
Size
(
354
,
16
);
this
.
labelCopyright
.
Size
=
new
System
.
Drawing
.
Size
(
354
,
16
);
this
.
labelCopyright
.
TabIndex
=
21
;
this
.
labelCopyright
.
TabIndex
=
21
;
this
.
labelCopyright
.
Tag
=
"not"
;
this
.
labelCopyright
.
Text
=
"版权"
;
this
.
labelCopyright
.
Text
=
"版权"
;
this
.
labelCopyright
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleLeft
;
this
.
labelCopyright
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleLeft
;
//
//
...
@@ -124,6 +125,7 @@ namespace AutoScanAndLabel
...
@@ -124,6 +125,7 @@ namespace AutoScanAndLabel
this
.
textBoxDescription
.
Size
=
new
System
.
Drawing
.
Size
(
354
,
116
);
this
.
textBoxDescription
.
Size
=
new
System
.
Drawing
.
Size
(
354
,
116
);
this
.
textBoxDescription
.
TabIndex
=
23
;
this
.
textBoxDescription
.
TabIndex
=
23
;
this
.
textBoxDescription
.
TabStop
=
false
;
this
.
textBoxDescription
.
TabStop
=
false
;
this
.
textBoxDescription
.
Tag
=
"not"
;
this
.
textBoxDescription
.
Text
=
"说明"
;
this
.
textBoxDescription
.
Text
=
"说明"
;
//
//
// okButton
// okButton
...
...
AutoScanAndLabel/AboutBox1.cs
查看文件 @
b237d19
...
@@ -18,7 +18,7 @@ namespace AutoScanAndLabel
...
@@ -18,7 +18,7 @@ namespace AutoScanAndLabel
this
.
Text
=
String
.
Format
(
crc
.
GetString
(
"Res0001"
,
"关于 {0}"
),
crc
.
GetString
(
"App_Title"
,
"自动贴标机"
));
this
.
Text
=
String
.
Format
(
crc
.
GetString
(
"Res0001"
,
"关于 {0}"
),
crc
.
GetString
(
"App_Title"
,
"自动贴标机"
));
this
.
labelProductName
.
Text
=
AssemblyProduct
;
this
.
labelProductName
.
Text
=
AssemblyProduct
;
this
.
labelVersion
.
Text
=
String
.
Format
(
crc
.
GetString
(
"Res0002"
,
"版本 {0}"
),
AssemblyVersion
);
this
.
labelVersion
.
Text
=
String
.
Format
(
crc
.
GetString
(
"Res0002"
,
"版本 {0}"
),
AssemblyVersion
);
this
.
labelCopyright
.
Text
=
crc
.
GetString
(
"Res0219"
,
"版权 © 2021"
)
;
this
.
labelCopyright
.
Text
=
AssemblyCopyright
;
this
.
labelCompanyName
.
Text
=
AssemblyCompany
;
this
.
labelCompanyName
.
Text
=
AssemblyCompany
;
this
.
textBoxDescription
.
Text
=
AssemblyDescription
;
this
.
textBoxDescription
.
Text
=
AssemblyDescription
;
}
}
...
@@ -63,10 +63,10 @@ namespace AutoScanAndLabel
...
@@ -63,10 +63,10 @@ namespace AutoScanAndLabel
{
{
int
days
=
Convert
.
ToInt32
(
strArray
[
2
]);
int
days
=
Convert
.
ToInt32
(
strArray
[
2
]);
int
seconds
=
Convert
.
ToInt32
(
strArray
[
3
]);
int
seconds
=
Convert
.
ToInt32
(
strArray
[
3
]);
DateTime
d1
=
DateTime
.
Parse
(
"20
24-06-06
"
);
DateTime
d1
=
DateTime
.
Parse
(
"20
00-01-01
"
);
//
var newData = d1.AddDays(days);
var
newData
=
d1
.
AddDays
(
days
);
//
newData = newData.AddSeconds(seconds * 2);
newData
=
newData
.
AddSeconds
(
seconds
*
2
);
updatetime
=
$
"{crc.GetString("
Res0220
", "
最后更新时间
:
")}"
+
d1
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
updatetime
=
$
"{crc.GetString("
Res0220
", "
最后更新时间
:
")}"
+
newData
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
}
}
if
(
attributes
.
Length
==
0
)
if
(
attributes
.
Length
==
0
)
...
...
AutoScanAndLabel/Program.cs
查看文件 @
b237d19
...
@@ -73,6 +73,7 @@ namespace AutoScanAndLabel
...
@@ -73,6 +73,7 @@ namespace AutoScanAndLabel
}
}
Environment
.
CurrentDirectory
=
Application
.
StartupPath
;
Environment
.
CurrentDirectory
=
Application
.
StartupPath
;
XmlConfigurator
.
Configure
();
XmlConfigurator
.
Configure
();
Config
.
LoadMyConfig
(
typeof
(
Setting_Init
));
Application
.
EnableVisualStyles
();
Application
.
EnableVisualStyles
();
Application
.
SetCompatibleTextRenderingDefault
(
false
);
Application
.
SetCompatibleTextRenderingDefault
(
false
);
Application
.
Run
(
new
Form1
());
Application
.
Run
(
new
Form1
());
...
...
AutoScanAndLabel/Properties/AssemblyInfo.cs
查看文件 @
b237d19
...
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
...
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Neotel")]
[assembly: AssemblyCompany("Neotel")]
[assembly: AssemblyProduct("NS200")]
[assembly: AssemblyProduct("NS200")]
[assembly: AssemblyCopyright("Copyright © 202
4
")]
[assembly: AssemblyCopyright("Copyright © 202
6
")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyCulture("")]
...
...
Common/Setting_Init.cs
查看文件 @
b237d19
using
System
;
using
ConfigHelper
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Globalization
;
using
System.Globalization
;
using
System.Linq
;
using
System.Linq
;
...
@@ -74,5 +75,14 @@ namespace OnlineStore.Common
...
@@ -74,5 +75,14 @@ namespace OnlineStore.Common
public
static
string
SMB_StorageUnitValue
=
"SMB_StorageUnitValue"
;
public
static
string
SMB_StorageUnitValue
=
"SMB_StorageUnitValue"
;
[
MyConfigComment
(
"设备项目号"
)]
public
static
MyConfig
<
Procjet_NO
>
ProcjetNO
=
Procjet_NO
.
General
;
}
public
enum
Procjet_NO
{
General
,
SO1340
}
}
}
}
DeviceLibrary/DeviceLibrary/CodeManager.cs
查看文件 @
b237d19
using
CodeLibrary
;
using
ConfigHelper
;
using
Newtonsoft.Json
;
using
OnlineStore.Common
;
using
OnlineStore.Common
;
using
OnlineStore.Common.util
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.Drawing
;
using
System.Drawing.Imaging
;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
using
System.Runtime.ExceptionServices
;
using
System.Runtime.ExceptionServices
;
using
System.Text
;
using
System.Windows.Forms
;
using
CodeLibrary
;
using
System.Drawing.Imaging
;
using
System.Text.RegularExpressions
;
using
System.Text.RegularExpressions
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
using
ConfigHelper
;
using
System.Reflection.Emit
;
using
static
RemoteDecodeHelper_mod
;
using
static
RemoteDecodeHelper_mod
;
using
System.Web
;
using
log4net
;
using
OnlineStore.Common.util
;
using
Newtonsoft.Json
;
namespace
DeviceLibrary
namespace
DeviceLibrary
{
{
...
@@ -53,7 +48,7 @@ namespace DeviceLibrary
...
@@ -53,7 +48,7 @@ namespace DeviceLibrary
}
}
LoadCamera
(
false
);
LoadCamera
(
false
);
iscode
=
Config
.
Get
<
bool
>(
"isStartscanningcode"
,
true
);
iscode
=
Config
.
Get
<
bool
>(
"isStartscanningcode"
,
true
);
LogUtil
.
info
(
"加载到扫码相机"
);
LogUtil
.
info
(
"加载到扫码相机"
);
if
(!
iscode
)
if
(!
iscode
)
{
{
...
@@ -143,7 +138,7 @@ namespace DeviceLibrary
...
@@ -143,7 +138,7 @@ namespace DeviceLibrary
}
}
[
HandleProcessCorruptedStateExceptions
]
[
HandleProcessCorruptedStateExceptions
]
public
static
(
List
<
CodeInfo
>,
Dictionary
<
string
,
string
>,
string
,
Dictionary
<
string
,
int
>)
CameraScan
(
List
<
string
>
cameraNameList
,
int
PlateW
)
public
static
(
List
<
CodeInfo
>,
Dictionary
<
string
,
string
>,
string
,
Dictionary
<
string
,
int
>)
CameraScan
(
List
<
string
>
cameraNameList
,
int
PlateW
)
{
{
List
<
CodeInfo
>
codeList
=
new
List
<
CodeInfo
>();
List
<
CodeInfo
>
codeList
=
new
List
<
CodeInfo
>();
Dictionary
<
string
,
string
>
keyword
=
new
Dictionary
<
string
,
string
>();
Dictionary
<
string
,
string
>
keyword
=
new
Dictionary
<
string
,
string
>();
...
@@ -174,11 +169,11 @@ namespace DeviceLibrary
...
@@ -174,11 +169,11 @@ namespace DeviceLibrary
_
=
Camera
.
_cam
.
CaptureOnImage
(
cameraName
,
out
bmp
,
out
List
<
CodeInfo
>
codes
,
nohalcon
);
_
=
Camera
.
_cam
.
CaptureOnImage
(
cameraName
,
out
bmp
,
out
List
<
CodeInfo
>
codes
,
nohalcon
);
if
(
bmp
==
null
)
if
(
bmp
==
null
)
{
{
LogUtil
.
error
(
" 【"
+
cameraName
+
"】取图片失败["
+
Camera
.
_cam
.
ErrInfo
+
"],关闭相机,重试:"
+
retry
);
LogUtil
.
error
(
" 【"
+
cameraName
+
"】取图片失败["
+
Camera
.
_cam
.
ErrInfo
+
"],关闭相机,重试:"
+
retry
);
Camera
.
_cam
.
CloseAll
();
Camera
.
_cam
.
CloseAll
();
//LoadCamera(true);
//LoadCamera(true);
retry
++;
retry
++;
if
(
retry
>
2
)
if
(
retry
>
2
)
continue
;
continue
;
goto
retry
;
goto
retry
;
}
}
...
@@ -186,15 +181,26 @@ namespace DeviceLibrary
...
@@ -186,15 +181,26 @@ namespace DeviceLibrary
WebResultCode
webResult
=
null
;
WebResultCode
webResult
=
null
;
if
(
iscode
)
if
(
iscode
)
{
{
if
(
codes
.
Count
==
0
)
if
(
codes
.
Count
==
0
)
{
{
//throw new FileNotFoundException("扫码相机未扫描到任何条码!");
//throw new FileNotFoundException("扫码相机未扫描到任何条码!");
LogUtil
.
error
(
"扫码相机未扫描到任何条码!"
);
LogUtil
.
error
(
"扫码相机未扫描到任何条码!"
);
return
(
codeList
,
keyword
,
bitmapfilename
,
newpointanlge
);
return
(
codeList
,
keyword
,
bitmapfilename
,
newpointanlge
);
}
}
LogUtil
.
info
(
"识别条码为:"
+
JsonConvert
.
SerializeObject
(
codes
));
LogUtil
.
info
(
"识别条码为:"
+
JsonConvert
.
SerializeObject
(
codes
));
if
(
Setting_Init
.
ProcjetNO
==
Procjet_NO
.
SO1340
)
{
var
rc
=
codes
.
RemoveAll
(
c
=>
{
var
ss
=
c
.
CodeStr
.
Count
(
cs
=>
cs
==
';'
);
return
(
ss
==
9
||
ss
==
10
)
&&
c
.
CodeStr
.
Contains
(
";NA;"
);
});
LogUtil
.
info
(
$
"SO1340 删除NA后条码 count:{rc} :"
+
JsonConvert
.
SerializeObject
(
codes
));
}
LogUtil
.
info
(
$
"开始请求ns100服务"
);
LogUtil
.
info
(
$
"开始请求ns100服务"
);
webResult
=
NeoSacnRequest
(
BitmapToBase64
(
bmp
),
codes
,
PlateW
,
RobotManage
.
Config
.
Right_Batch_X
,
RobotManage
.
Config
.
Right_Batch_Y
);
webResult
=
NeoSacnRequest
(
BitmapToBase64
(
bmp
),
codes
,
PlateW
,
RobotManage
.
Config
.
Right_Batch_X
,
RobotManage
.
Config
.
Right_Batch_Y
);
}
}
else
else
{
{
...
@@ -233,20 +239,20 @@ namespace DeviceLibrary
...
@@ -233,20 +239,20 @@ namespace DeviceLibrary
}
}
}
}
newpointanlge
.
Add
(
"PointX"
,
webResult
.
positionAngle
.
X
);
newpointanlge
.
Add
(
"PointX"
,
webResult
.
positionAngle
.
X
);
newpointanlge
.
Add
(
"PointY"
,
webResult
.
positionAngle
.
Y
);
newpointanlge
.
Add
(
"PointY"
,
webResult
.
positionAngle
.
Y
);
newpointanlge
.
Add
(
"Angle"
,
webResult
.
positionAngle
.
Angle
);
newpointanlge
.
Add
(
"Angle"
,
webResult
.
positionAngle
.
Angle
);
if
(
webResult
.
positionAngle
.
IsCodeUsed
!=
null
)
if
(
webResult
.
positionAngle
.
IsCodeUsed
!=
null
)
{
{
newpointanlge
.
Add
(
"IsCodeUsed"
,
Array
.
FindIndex
(
webResult
.
positionAngle
.
IsCodeUsed
,
x
=>
x
));
;
newpointanlge
.
Add
(
"IsCodeUsed"
,
Array
.
FindIndex
(
webResult
.
positionAngle
.
IsCodeUsed
,
x
=>
x
));
;
}
}
LogUtil
.
info
(
$
"贴标数据X={webResult.positionAngle.X};Y={webResult.positionAngle.Y};角度={webResult.positionAngle.Angle}"
);
LogUtil
.
info
(
$
"贴标数据X={webResult.positionAngle.X};Y={webResult.positionAngle.Y};角度={webResult.positionAngle.Angle}"
);
if
(
bmp
!=
null
)
if
(
bmp
!=
null
)
{
{
string
cid
=
ConfigHelper
.
Config
.
Get
(
"CID"
);
string
cid
=
ConfigHelper
.
Config
.
Get
(
"CID"
);
_
=
UnifiedDataHandler
.
PostSmfImageAsync
(
bmp
,
new
Dictionary
<
string
,
string
>
{
{
"cid"
,
cid
+
"_1"
}
});
_
=
UnifiedDataHandler
.
PostSmfImageAsync
(
bmp
,
new
Dictionary
<
string
,
string
>
{
{
"cid"
,
cid
+
"_1"
}
});
}
}
LogUtil
.
info
(
" 【"
+
cameraName
+
"】"
+
" 扫码完成【"
+
FormUtil
.
GetSpanStr
(
DateTime
.
Now
-
startTime
)
+
"】"
);
LogUtil
.
info
(
" 【"
+
cameraName
+
"】"
+
" 扫码完成【"
+
FormUtil
.
GetSpanStr
(
DateTime
.
Now
-
startTime
)
+
"】"
);
}
}
}
}
catch
(
AccessViolationException
e
)
catch
(
AccessViolationException
e
)
...
@@ -269,11 +275,11 @@ namespace DeviceLibrary
...
@@ -269,11 +275,11 @@ namespace DeviceLibrary
}
}
catch
(
AccessViolationException
e
)
catch
(
AccessViolationException
e
)
{
{
LogUtil
.
error
(
" 扫码出现AccessViolationException异常:"
+
e
.
ToString
());
LogUtil
.
error
(
" 扫码出现AccessViolationException异常:"
+
e
.
ToString
());
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
" 扫码出错:"
+
ex
.
ToString
());
LogUtil
.
error
(
" 扫码出错:"
+
ex
.
ToString
());
}
}
return
(
codeList
,
keyword
,
bitmapfilename
,
newpointanlge
);
return
(
codeList
,
keyword
,
bitmapfilename
,
newpointanlge
);
}
}
...
@@ -349,7 +355,8 @@ namespace DeviceLibrary
...
@@ -349,7 +355,8 @@ namespace DeviceLibrary
/// <param name="pX"></param>
/// <param name="pX"></param>
/// <param name="pY"></param>
/// <param name="pY"></param>
/// <returns>x,y</returns>
/// <returns>x,y</returns>
static
(
int
,
int
)
PointRoate270
(
int
imgWidth
,
int
imgHeight
,
int
pX
,
int
pY
)
{
static
(
int
,
int
)
PointRoate270
(
int
imgWidth
,
int
imgHeight
,
int
pX
,
int
pY
)
{
int
x
=
pY
;
int
x
=
pY
;
int
y
=
imgWidth
-
pX
;
int
y
=
imgWidth
-
pX
;
return
(
x
,
y
);
return
(
x
,
y
);
...
@@ -357,7 +364,7 @@ namespace DeviceLibrary
...
@@ -357,7 +364,7 @@ namespace DeviceLibrary
private
static
string
SaveImageToFile
(
string
deviceName
,
string
cameraName
,
Bitmap
bitmap
)
private
static
string
SaveImageToFile
(
string
deviceName
,
string
cameraName
,
Bitmap
bitmap
)
{
{
string
date
=
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd-HH-mm-ss"
)
+
DateTime
.
Now
.
Millisecond
;
string
date
=
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd-HH-mm-ss"
)
+
DateTime
.
Now
.
Millisecond
;
string
dire
=
Application
.
StartupPath
+
@"\image\" + deviceName.Trim().Replace('_', '-') + @"
\
" + cameraName.Trim().Replace('_', '-').Replace(':', '-') + @"
\
";
string
dire
=
Application
.
StartupPath
+
@"\image\" + deviceName.Trim().Replace('_', '-') + @"
\
" + cameraName.Trim().Replace('_', '-').Replace(':', '-') + @"
\
";
string
iamgeName
=
date
+
".bmp"
;
string
iamgeName
=
date
+
".bmp"
;
try
try
{
{
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论