Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张东亮
/
NS100
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit e778911b
由
王海洋
编写于
2025-05-08 11:01:57 +0800
浏览文件
选项
浏览文件
标签
下载
差异文件
Merge branch 'master' of
http://106.15.194.121:8083/zdl/NS100
2 个父辈
34242b4e
8f614d2c
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
63 行增加
和
38 行删除
BLL/BLLCommon.cs
BLL/MatchAnalysis.cs
BLL/MaterialEdit.cs
Model/FilePath.cs
Model/MaterialAsciiCode.cs
SmartScan/Form/FrmCodeExtract.cs
SmartScan/Program.cs
SmartScan/SetControl/UsrCodeExtractList.cs
SmartScan/SetControl/UsrMaterialTemplate.cs
BLL/BLLCommon.cs
查看文件 @
e778911
...
...
@@ -20,7 +20,7 @@ namespace BLL
public
static
List
<
string
>
extraKey
=
new
List
<
string
>();
//public static Dictionary<string, Dictionary<string, string>> extraData = new Dictionary<string, Dictionary<string, string>>();
public
static
int
mateMaxCodeID
;
public
static
readonly
string
[]
CODE_SPLIT
=
new
string
[]
{
","
,
";"
,
":"
,
"@"
,
"#"
,
"$"
,
"%"
,
"&"
,
"-"
,
"_"
,
"+"
,
"|"
,
"!"
,
"^"
,
"*"
,
"?"
,
"/"
,
"\\"
,
"[Space]"
,
"[Tab]"
,
"[GS]"
,
"[RS]"
};
public
static
readonly
string
[]
CODE_SPLIT
=
new
string
[]
{
","
,
";"
,
":"
,
"@"
,
"#"
,
"$"
,
"%"
,
"&"
,
"-"
,
"_"
,
"+"
,
"|"
,
"!"
,
"^"
,
"*"
,
"?"
,
"/"
,
"\\"
,
"[Space]"
,
"[Tab]"
,
"[GS]"
,
"[RS]"
,
"[LF]"
};
public
static
List
<
AutoGenRule
>
AutoGenRules
;
}
...
...
BLL/MatchAnalysis.cs
查看文件 @
e778911
...
...
@@ -68,11 +68,10 @@ namespace BLL
{
//return;
foreach
(
var
tp
in
MatchTemplateList
)
{
LogNet
.
log
.
Info
(
$
"开始解析模版:{tp.Key}"
);
LogNet
.
log
.
Info
(
$
"
===
开始解析模版:{tp.Key}"
);
foreach
(
var
m
in
tp
.
Value
.
MatchCollections
)
{
LogNet
.
log
.
Info
(
$
"开始解析关键字:{m.Key}"
);
//LogNet.log.Info($"匹配到关键字:{m.Key}");
string
matchlist
=
m
.
Value
.
barcodeInfo
.
Text
+
"\t/\t"
;
foreach
(
var
item
in
m
.
Value
.
Matchs
)
{
...
...
@@ -80,6 +79,7 @@ namespace BLL
}
LogNet
.
log
.
Info
(
matchlist
);
}
LogNet
.
log
.
Info
(
$
"===结束解析模版:{tp.Key}"
);
}
}
public
class
TemplateCollection
...
...
BLL/MaterialEdit.cs
查看文件 @
e778911
...
...
@@ -619,8 +619,11 @@ namespace BLL
{
int
matchCount
=
0
;
var
codeText
=
codeinfo
.
Text
;
codeText
=
codeText
.
Replace
(
"\r"
,
""
);
codeText
=
codeText
.
Replace
(
"\n"
,
""
);
if
(
codeinfo
.
CodeType
==
"OCR"
)
{
codeText
=
codeText
.
Replace
(
"\r"
,
""
);
codeText
=
codeText
.
Replace
(
"\n"
,
""
);
}
MatchAnalysis
.
SetBarcode
(
codeinfo
);
code
=
codeMatch
[
i
].
CaseSensitive
?
codeText
:
codeText
.
ToUpper
();
bool
ismatch
=
true
;
...
...
@@ -649,7 +652,7 @@ namespace BLL
if
(!
code
.
StartsWith
(
text
))
ismatch
=
false
;
MatchAnalysis
.
AddMatch
(
codeMatch
[
i
].
Keyword
,
ismatch
,
codeMatch
[
i
].
CodeID
,
$
"开头字符:\"{text}\""
,
$
"NG"
);
MatchAnalysis
.
AddMatch
(
codeMatch
[
i
].
Keyword
,
ismatch
,
codeMatch
[
i
].
CodeID
,
$
"开头字符:\"{text}\""
,
ismatch
?
"OK"
:
"NG"
);
//if (!ismatch) return null;
}
...
...
@@ -662,7 +665,7 @@ namespace BLL
if
(!
code
.
EndsWith
(
text
))
ismatch
=
false
;
MatchAnalysis
.
AddMatch
(
codeMatch
[
i
].
Keyword
,
ismatch
,
codeMatch
[
i
].
CodeID
,
$
"结尾字符:\"{text}\""
,
$
"NG"
);
MatchAnalysis
.
AddMatch
(
codeMatch
[
i
].
Keyword
,
ismatch
,
codeMatch
[
i
].
CodeID
,
$
"结尾字符:\"{text}\""
,
ismatch
?
"OK"
:
"NG"
);
//if (!ismatch) return null;
}
...
...
@@ -689,7 +692,7 @@ namespace BLL
ismatch
=
false
;
var
mode
=
codeMatch
[
i
].
MatchMiddleType
==
0
?
"相等"
:
codeMatch
[
i
].
MatchMiddleType
==
1
?
"至多"
:
"至少"
;
MatchAnalysis
.
AddMatch
(
codeMatch
[
i
].
Keyword
,
ismatch
,
codeMatch
[
i
].
CodeID
,
$
"中间字符:\"{text}\",{mode}匹配:{codeMatch[i].MiddleTextCount}次"
,
$
"NG"
);
MatchAnalysis
.
AddMatch
(
codeMatch
[
i
].
Keyword
,
ismatch
,
codeMatch
[
i
].
CodeID
,
$
"中间字符:\"{text}\",{mode}匹配:{codeMatch[i].MiddleTextCount}次"
,
ismatch
?
"OK"
:
"NG"
);
//if (!ismatch) return null;
}
...
...
@@ -702,7 +705,7 @@ namespace BLL
string
str
=
MaterialAsciiCode
.
GetAsciiCode
(
codeMatch
[
i
].
SplitText
);
if
(
codeText
.
Contains
(
str
))
{
string
[]
arr
=
codeText
.
Split
(
new
string
[]
{
str
},
StringSplitOptions
.
RemoveEmptyEntries
);
string
[]
arr
=
codeText
.
Split
(
str
.
ToCharArray
()
);
index
=
codeMatch
[
i
].
SplitPart
-
1
;
if
(
index
>=
arr
.
Length
)
ismatch
=
false
;
...
...
@@ -714,7 +717,7 @@ namespace BLL
ismatch
=
false
;
}
MatchAnalysis
.
AddMatch
(
codeMatch
[
i
].
Keyword
,
ismatch
,
codeMatch
[
i
].
CodeID
,
$
"分割符:{codeMatch[i].SplitText},第:{codeMatch[i].SplitPart}位"
,
$
"NG"
);
MatchAnalysis
.
AddMatch
(
codeMatch
[
i
].
Keyword
,
ismatch
,
codeMatch
[
i
].
CodeID
,
$
"分割符:{codeMatch[i].SplitText},第:{codeMatch[i].SplitPart}位"
,
ismatch
?
"OK"
:
"NG"
);
//if (!ismatch) return null;
}
...
...
@@ -740,13 +743,14 @@ namespace BLL
if
(
codeMatch
[
i
].
MatchISNumber
)
{
LogNet
.
log
.
Info
(
$
"开始匹配数字 [{filtercode}]"
);
string
analysisReason
=
$
"\"{filtercode}\""
;
filtercode
=
filtercode
.
Trim
().
ToLower
().
Replace
(
"pcs"
,
""
);
filtercode
=
filtercode
.
Replace
(
","
,
""
);
string
analysisReason
=
filtercode
;
if
(!
int
.
TryParse
(
filtercode
,
out
int
res
))
{
ismatch
=
false
;
analysisReason
+=
$
" NG"
;
}
else
{
...
...
@@ -765,7 +769,7 @@ namespace BLL
//bool ismatch = true;
if
(
code
.
Length
<
codeMatch
[
i
].
MinLength
)
ismatch
=
false
;
MatchAnalysis
.
AddMatch
(
codeMatch
[
i
].
Keyword
,
ismatch
,
codeMatch
[
i
].
CodeID
,
$
"长度
小于:{codeMatch[i].MatchMinLength}"
,
$
"NG"
);
MatchAnalysis
.
AddMatch
(
codeMatch
[
i
].
Keyword
,
ismatch
,
codeMatch
[
i
].
CodeID
,
$
"长度
最小:{codeMatch[i].MinLength}"
,
ismatch
?
"OK"
:
"NG"
);
//if (!ismatch) return null;
}
...
...
@@ -776,7 +780,7 @@ namespace BLL
//bool ismatch = true;
if
(
code
.
Length
>
codeMatch
[
i
].
MaxLength
)
ismatch
=
false
;
MatchAnalysis
.
AddMatch
(
codeMatch
[
i
].
Keyword
,
ismatch
,
codeMatch
[
i
].
CodeID
,
$
"长度最大:{codeMatch[i].Ma
tchMaxLength}"
,
$
"NG"
);
MatchAnalysis
.
AddMatch
(
codeMatch
[
i
].
Keyword
,
ismatch
,
codeMatch
[
i
].
CodeID
,
$
"长度最大:{codeMatch[i].Ma
xLength}"
,
ismatch
?
"OK"
:
"NG"
);
}
if
(!
ismatch
)
...
...
Model/FilePath.cs
查看文件 @
e778911
...
...
@@ -12,19 +12,19 @@ namespace Model
/// </summary>
public
static
class
FilePath
{
public
static
readonly
string
LANGUAGE_DIR
=
Environment
.
CurrentDirectory
+
"\\Language\\"
;
public
static
readonly
string
MATERIAL_DIR
=
Environment
.
CurrentDirectory
+
"\\Material\\"
;
public
static
readonly
string
LANGUAGE_DIR
=
Application
.
StartupPath
+
"\\Language\\"
;
public
static
readonly
string
MATERIAL_DIR
=
Application
.
StartupPath
+
"\\Material\\"
;
public
static
readonly
string
RETROSPECT_DIR
=
Application
.
StartupPath
+
"\\Retrospect\\"
;
public
static
readonly
string
PRINT_LABEL_DIR
=
Environment
.
CurrentDirectory
+
"\\PrintLabel\\"
;
public
static
readonly
string
CONFIG_DIR
=
Environment
.
CurrentDirectory
+
"\\Config\\"
;
public
static
readonly
string
PRINT_LABEL_DIR
=
Application
.
StartupPath
+
"\\PrintLabel\\"
;
public
static
readonly
string
CONFIG_DIR
=
Application
.
StartupPath
+
"\\Config\\"
;
public
static
readonly
string
CONFIG_APP
=
Environment
.
CurrentDirectory
+
"\\Config\\app.config"
;
public
static
readonly
string
CONFIG_CAMERA
=
Environment
.
CurrentDirectory
+
"\\Config\\Camera.json"
;
public
static
readonly
string
CONFIG_MACRO_KEY
=
Environment
.
CurrentDirectory
+
"\\Config\\MacroKey.txt"
;
public
static
readonly
string
CONFIG_HTTP_TEST_DATA
=
Environment
.
CurrentDirectory
+
"\\Config\\HttpTestData.json"
;
public
static
readonly
string
CONFIG_EXTENSION
=
Environment
.
CurrentDirectory
+
"\\Config\\Extension.json"
;
public
static
readonly
string
CONFIG_REELID
=
Environment
.
CurrentDirectory
+
"\\Config\\ReelID"
;
public
static
readonly
string
CONFIG_DATABASE
=
Environment
.
CurrentDirectory
+
"\\Config\\Database.db3"
;
public
static
readonly
string
CONFIG_AUTOGENRULES
=
Environment
.
CurrentDirectory
+
"\\Config\\AutoGenRules.json"
;
public
static
readonly
string
CONFIG_APP
=
Application
.
StartupPath
+
"\\Config\\app.config"
;
public
static
readonly
string
CONFIG_CAMERA
=
Application
.
StartupPath
+
"\\Config\\Camera.json"
;
public
static
readonly
string
CONFIG_MACRO_KEY
=
Application
.
StartupPath
+
"\\Config\\MacroKey.txt"
;
public
static
readonly
string
CONFIG_HTTP_TEST_DATA
=
Application
.
StartupPath
+
"\\Config\\HttpTestData.json"
;
public
static
readonly
string
CONFIG_EXTENSION
=
Application
.
StartupPath
+
"\\Config\\Extension.json"
;
public
static
readonly
string
CONFIG_REELID
=
Application
.
StartupPath
+
"\\Config\\ReelID"
;
public
static
readonly
string
CONFIG_DATABASE
=
Application
.
StartupPath
+
"\\Config\\Database.db3"
;
public
static
readonly
string
CONFIG_AUTOGENRULES
=
Application
.
StartupPath
+
"\\Config\\AutoGenRules.json"
;
}
}
Model/MaterialAsciiCode.cs
查看文件 @
e778911
...
...
@@ -8,7 +8,7 @@ namespace Model
{
public
static
class
MaterialAsciiCode
{
private
static
readonly
Dictionary
<
string
,
string
>
ASCII_CODE
=
new
()
{
{
"[space]"
,
" "
},
{
"[tab]"
,
"\t"
},{
"[gs]"
,((
char
)
29
).
ToString
()},{
"[rs]"
,
((
char
)
30
).
ToString
()
}
};
private
static
readonly
Dictionary
<
string
,
string
>
ASCII_CODE
=
new
()
{
{
"[space]"
,
" "
},
{
"[tab]"
,
"\t"
},{
"[gs]"
,((
char
)
29
).
ToString
()},{
"[rs]"
,
((
char
)
30
).
ToString
()
}
,
{
"[lf]"
,
((
char
)
10
).
ToString
()
}
};
public
static
string
GetAsciiCode
(
string
code
)
{
...
...
SmartScan/Form/FrmCodeExtract.cs
查看文件 @
e778911
...
...
@@ -29,8 +29,12 @@ namespace SmartScan
{
InitializeComponent
();
windowHeight
=
this
.
Height
;
codeText
=
codeText
.
Replace
(
"\r"
,
""
);
this
.
codeText
=
codeText
.
Replace
(
"\n"
,
""
);
this
.
codeText
=
codeText
;
if
(
codeType
==
"OCR"
)
{
codeText
=
codeText
.
Replace
(
"\r"
,
""
);
this
.
codeText
=
codeText
.
Replace
(
"\n"
,
""
);
}
this
.
codeID
=
codeID
;
this
.
codeType
=
codeType
;
TxtMatchingEndText
.
Tag
=
"not"
;
...
...
SmartScan/Program.cs
查看文件 @
e778911
...
...
@@ -102,6 +102,7 @@ namespace SmartScan
Application
.
SetCompatibleTextRenderingDefault
(
false
);
//BLL.Config.Backgrounder = true;
bool
back
=
BLL
.
Config
.
Backgrounder
;
bool
hide
=
false
;
if
(
args
.
Length
>
0
)
hide
=
args
[
0
].
ToLower
()
==
"hide"
;
...
...
SmartScan/SetControl/UsrCodeExtractList.cs
查看文件 @
e778911
...
...
@@ -130,7 +130,7 @@ namespace SmartScan
//string outup = codeText;
//AsciiToCharReplacer asciiToChar = new AsciiToCharReplacer();
//outup= asciiToChar.AsciiToString(outup);
string
[]
arr
=
text
.
Split
(
new
string
[]
{
str
},
StringSplitOptions
.
RemoveEmptyEntries
);
string
[]
arr
=
text
.
Split
(
str
.
ToCharArray
()
);
//string[] arr = codeText.Split(new string[] { str }, StringSplitOptions.RemoveEmptyEntries);
int
index
=
Convert
.
ToInt32
(
NudSplitPart
.
Value
)
-
1
;
...
...
SmartScan/SetControl/UsrMaterialTemplate.cs
查看文件 @
e778911
using
System
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.Drawing.Imaging
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Web.UI.WebControls
;
using
System.Windows.Forms
;
using
Asa.FaceControl
;
...
...
@@ -310,13 +313,23 @@ namespace SmartScan
bmp
=
ObjConversion
.
ReadImageFile
(
dlg
.
FileName
);
LstCode
.
Items
.
Clear
();
ImgShow
.
CodeCenterClear
();
//ImgShow.Image = null;
mateCopy
[
mateIndex
].
State
=
TemplateState
.
Unsaved
;
mateCopy
[
mateIndex
].
ImagePath
=
""
;
mateCopy
[
mateIndex
].
Image
=
bmp
;
ImgShow
.
Image
=
bmp
;
Application
.
DoEvents
();
ImgShow
.
Image
=
bmp
;
// ConvertTo24bppRgb(bmp);
iscamp
=
false
;
}
public
Bitmap
ConvertTo24bppRgb
(
Bitmap
argbImage
)
{
Bitmap
rgbImage
=
new
Bitmap
(
argbImage
.
Width
,
argbImage
.
Height
,
PixelFormat
.
Format24bppRgb
);
using
(
Graphics
g
=
Graphics
.
FromImage
(
rgbImage
))
{
g
.
DrawImage
(
argbImage
,
new
Rectangle
(
0
,
0
,
rgbImage
.
Width
,
rgbImage
.
Height
));
}
return
rgbImage
;
}
public
bool
iscamp
=
true
;
private
void
BtnScanCode_Click
(
object
sender
,
EventArgs
e
)
{
...
...
@@ -329,7 +342,8 @@ namespace SmartScan
return
;
}
List
<
BarcodeInfo
>
info
=
null
;
LstCode
.
Items
.
Clear
();
ImgShow
.
CodeCenterClear
();
if
(
iscamp
&&
Camera
.
useIDCamera
)
{
Bitmap
[]
result
=
Camera
.
CaptureAndGetCode
(
out
info
);
...
...
@@ -345,8 +359,7 @@ namespace SmartScan
}
//info = Camera.GetBarCode(bmp);
LstCode
.
Items
.
Clear
();
ImgShow
.
CodeCenterClear
();
mateCopy
[
mateIndex
].
Match
.
Clear
();
mateCopy
[
mateIndex
].
Code
.
Clear
();
mateCopy
[
mateIndex
].
Ocr
.
Clear
();
...
...
@@ -767,8 +780,11 @@ namespace SmartScan
{
int
matchCount
=
0
;
var
codeText
=
codeinfo
.
Text
;
codeText
=
codeText
.
Replace
(
"\r"
,
""
);
codeText
=
codeText
.
Replace
(
"\n"
,
""
);
if
(
codeinfo
.
CodeType
==
"OCR"
)
{
codeText
=
codeText
.
Replace
(
"\r"
,
""
);
codeText
=
codeText
.
Replace
(
"\n"
,
""
);
}
code
=
codeMatch
[
i
].
CaseSensitive
?
codeText
:
codeText
.
ToUpper
();
bool
ismatch
=
true
;
//匹配CodeType
...
...
@@ -831,7 +847,7 @@ namespace SmartScan
string
str
=
MaterialAsciiCode
.
GetAsciiCode
(
codeMatch
[
i
].
SplitText
);
if
(
codeText
.
Contains
(
str
))
{
string
[]
arr
=
codeText
.
Split
(
new
string
[]
{
str
},
StringSplitOptions
.
RemoveEmptyEntries
);
string
[]
arr
=
codeText
.
Split
(
str
.
ToCharArray
()
);
index
=
codeMatch
[
i
].
SplitPart
-
1
;
if
(
index
>=
arr
.
Length
)
ismatch
=
false
;
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论