Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张东亮
/
NS100
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit f9bd0599
由
刘韬
编写于
2026-01-30 13:19:14 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
同一模板中关键字匹配到不同的内容则NG处理
1 个父辈
99de8ba5
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
36 行增加
和
41 行删除
BLL/Extension/Item_General.cs
BLL/MaterialEdit.cs
SmartScan/ScanWork.cs
BLL/Extension/Item_General.cs
查看文件 @
f9bd059
...
@@ -128,7 +128,7 @@ namespace BLL
...
@@ -128,7 +128,7 @@ namespace BLL
for
(
int
i
=
0
;
i
<
extensions
.
Count
;
i
++)
for
(
int
i
=
0
;
i
<
extensions
.
Count
;
i
++)
{
{
extensions
[
i
].
Control
.
ForeColor
=
System
.
Drawing
.
Color
.
White
;
extensions
[
i
].
Control
.
ForeColor
=
System
.
Drawing
.
Color
.
White
;
if
(
key
.
ContainsKey
(
extensions
[
i
].
Key
))
if
(
!
string
.
IsNullOrEmpty
(
extensions
[
i
].
Key
)
&&
key
.
ContainsKey
(
extensions
[
i
].
Key
))
extensions
[
i
].
Control
.
Text
=
key
[
extensions
[
i
].
Key
].
Replace
(
"<OCR>"
,
""
);
extensions
[
i
].
Control
.
Text
=
key
[
extensions
[
i
].
Key
].
Replace
(
"<OCR>"
,
""
);
if
(
extensions
[
i
].
LinkName
==
"ischeckresult"
&&
lastKeys
!=
null
)
if
(
extensions
[
i
].
LinkName
==
"ischeckresult"
&&
lastKeys
!=
null
)
{
{
...
@@ -416,7 +416,7 @@ namespace BLL
...
@@ -416,7 +416,7 @@ namespace BLL
try
try
{
{
LogNet
.
log
.
Info
(
$
"接口上传信息 url: {config.HttpReelID.Trim()}, data: {JsonConvert.SerializeObject(key)}"
);
LogNet
.
log
.
Info
(
$
"接口上传信息 url: {config.HttpReelID.Trim()}, data: {JsonConvert.SerializeObject(key)}"
);
if
(!
string
.
IsNullOrEmpty
(
config
.
HttpReelID
.
Trim
()))
if
(!
string
.
IsNullOrEmpty
(
config
.
HttpReelID
.
Trim
())
&&
config
.
HttpReelID
.
Trim
().
ToLower
().
StartsWith
(
"http"
)
)
{
{
Dictionary
<
string
,
object
>
pairs
=
new
Dictionary
<
string
,
object
>();
Dictionary
<
string
,
object
>
pairs
=
new
Dictionary
<
string
,
object
>();
if
(!
GetHttpReelID
(
key
,
out
errmsg
,
out
pairs
))
if
(!
GetHttpReelID
(
key
,
out
errmsg
,
out
pairs
))
...
...
BLL/MaterialEdit.cs
查看文件 @
f9bd059
...
@@ -144,7 +144,7 @@ namespace BLL
...
@@ -144,7 +144,7 @@ namespace BLL
Directory
.
Delete
(
"ocr"
,
true
);
Directory
.
Delete
(
"ocr"
,
true
);
mateName
=
""
;
mateName
=
""
;
keyword
=
n
ull
;
keyword
=
n
ew
Dictionary
<
string
,
string
>()
;
LogNet
.
log
.
Info
(
$
"code数量:{code.Count}"
);
LogNet
.
log
.
Info
(
$
"code数量:{code.Count}"
);
code
.
ForEach
((
c
)
=>
code
.
ForEach
((
c
)
=>
{
{
...
@@ -169,45 +169,21 @@ namespace BLL
...
@@ -169,45 +169,21 @@ namespace BLL
LogNet
.
log
.
Info
(
$
"OCR 识别结果:{regOcrCodes}"
);
LogNet
.
log
.
Info
(
$
"OCR 识别结果:{regOcrCodes}"
);
}
}
//优先匹配
// 按优先级排序:firstMaterial > 有主键 > 无主键
int
firstIndex
=
mateTemp
.
FindIndex
(
math
=>
math
.
Name
==
firstMaterial
);
var
sortedList
=
mateTemp
if
(
firstIndex
>
-
1
)
.
Select
((
item
,
index
)
=>
new
{
Item
=
item
,
OriginalIndex
=
index
})
{
.
OrderByDescending
(
x
=>
x
.
Item
.
Name
==
firstMaterial
)
// 第一优先级
if
(
TemplateExtract
(
firstIndex
,
code
,
out
keyword
,
out
aMatch
))
.
ThenByDescending
(
x
=>
x
.
Item
.
PrimaryCode
!=
-
1
)
// 第二优先级
{
.
ThenBy
(
x
=>
x
.
OriginalIndex
)
// 保持原有顺序
//if (string.IsNullOrEmpty(mateName))
.
ToList
();
mateName
=
mateTemp
[
firstIndex
].
Name
;
if
(!
analyisMode
)
return
true
;
}
}
//优先判断带主键的
for
(
int
i
=
0
;
i
<
mateTemp
.
Count
;
i
++)
{
if
(
i
==
firstIndex
)
continue
;
if
(
mateTemp
[
i
].
PrimaryCode
==
-
1
)
continue
;
int
index
=
mateTemp
[
i
].
Code
.
FindIndex
(
match
=>
match
.
ID
==
mateTemp
[
i
].
PrimaryCode
);
if
(
index
==
-
1
)
continue
;
string
text
=
mateTemp
[
i
].
Match
.
Find
(
m
=>
m
.
CodeID
==
mateTemp
[
i
].
Code
[
index
].
ID
).
Keyword
;
if
(
TemplateExtract
(
i
,
code
,
out
keyword
,
out
aMatch
))
{
//if (string.IsNullOrEmpty(mateName))
mateName
=
mateTemp
[
i
].
Name
;
if
(!
analyisMode
)
return
true
;
}
}
//剩余不带主键的
for
(
int
i
=
0
;
i
<
mateTemp
.
Count
;
i
++)
for
(
int
i
=
0
;
i
<
mateTemp
.
Count
;
i
++)
{
{
if
(
i
==
firstIndex
)
continue
;
if
(
TemplateExtract
(
i
,
code
,
out
Dictionary
<
string
,
string
>
ckeyword
,
out
AMatch
caMatch
))
if
(
mateTemp
[
i
].
PrimaryCode
!=
-
1
)
continue
;
if
(
TemplateExtract
(
i
,
code
,
out
keyword
,
out
aMatch
))
{
{
//if (string.IsNullOrEmpty(mateName))
mateName
=
mateTemp
[
i
].
Name
;
mateName
=
mateTemp
[
i
].
Name
;
keyword
=
ckeyword
;
aMatch
=
caMatch
;
if
(!
analyisMode
)
if
(!
analyisMode
)
return
true
;
return
true
;
}
}
...
@@ -408,6 +384,7 @@ namespace BLL
...
@@ -408,6 +384,7 @@ namespace BLL
aMatch
.
IsCodeUsed
=
new
bool
[
code
.
Count
];
aMatch
.
IsCodeUsed
=
new
bool
[
code
.
Count
];
int
matchCount
=
0
;
int
matchCount
=
0
;
bool
isMatch
=
false
;
bool
isMatch
=
false
;
bool
匹配冲突
=
false
;
List
<
MaterialCode
>
ocrlist
=
new
List
<
MaterialCode
>();
List
<
MaterialCode
>
ocrlist
=
new
List
<
MaterialCode
>();
List
<
BarcodeInfo
>
ocrcode
=
new
List
<
BarcodeInfo
>();
List
<
BarcodeInfo
>
ocrcode
=
new
List
<
BarcodeInfo
>();
//命中规则的条码索引
//命中规则的条码索引
...
@@ -416,7 +393,7 @@ namespace BLL
...
@@ -416,7 +393,7 @@ namespace BLL
for
(
int
i
=
0
;
i
<
id
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
id
.
Length
;
i
++)
{
{
MatchAnalysis
.
SetTemplatename
(
mateTemp
[
index
].
Name
);
MatchAnalysis
.
SetTemplatename
(
mateTemp
[
index
].
Name
);
LogNet
.
log
.
Info
(
$
"开始匹配模版: {mateTemp[index].Name}"
);
LogNet
.
log
.
Info
(
$
"开始匹配模版: {mateTemp[index].Name}
, codeid:{id[i]}
"
);
List
<
MaterialCodeMatch
>
codeMatch
=
mateTemp
[
index
].
Match
.
FindAll
(
match
=>
match
.
CodeID
==
id
[
i
]
&&
match
.
Keyword
!=
""
);
List
<
MaterialCodeMatch
>
codeMatch
=
mateTemp
[
index
].
Match
.
FindAll
(
match
=>
match
.
CodeID
==
id
[
i
]
&&
match
.
Keyword
!=
""
);
if
(
codeMatch
.
Count
==
0
)
continue
;
if
(
codeMatch
.
Count
==
0
)
continue
;
matchCount
+=
codeMatch
.
Count
;
matchCount
+=
codeMatch
.
Count
;
...
@@ -442,9 +419,16 @@ namespace BLL
...
@@ -442,9 +419,16 @@ namespace BLL
keyword
.
Add
(
key
,
matchKey
[
key
]);
keyword
.
Add
(
key
,
matchKey
[
key
]);
LogNet
.
log
.
Info
(
$
"{mateTemp[index].Name} 匹配 [{key}={matchKey[key]}]"
);
LogNet
.
log
.
Info
(
$
"{mateTemp[index].Name} 匹配 [{key}={matchKey[key]}]"
);
}
}
else
{
if
(
matchKey
[
key
]
!=
keyword
[
key
])
{
LogNet
.
log
.
Info
(
$
"{mateTemp[index].Name} 匹配冲突 [{key}:{matchKey[key]} != {keyword[key]}]"
);
匹配冲突
=
true
;
}
}
}
}
}
}
}
}
}
}
LogNet
.
log
.
Info
(
$
"{mateTemp[index].Name} 匹配数量 [关键字数量:{keyword.Count} = 匹配数量:{matchCount}]"
);
LogNet
.
log
.
Info
(
$
"{mateTemp[index].Name} 匹配数量 [关键字数量:{keyword.Count} = 匹配数量:{matchCount}]"
);
...
@@ -478,6 +462,14 @@ namespace BLL
...
@@ -478,6 +462,14 @@ namespace BLL
ocrCount
--;
ocrCount
--;
LogNet
.
log
.
Info
(
$
"{mateTemp[index].Name} OCR匹配 [{key}={value}]"
);
LogNet
.
log
.
Info
(
$
"{mateTemp[index].Name} OCR匹配 [{key}={value}]"
);
}
}
else
{
if
(
matchKey
[
key
]
!=
keyword
[
key
])
{
LogNet
.
log
.
Info
(
$
"{mateTemp[index].Name} OCR匹配冲突 [{key}:{matchKey[key]} != {keyword[key]}]"
);
匹配冲突
=
true
;
}
}
}
}
}
}
}
}
...
@@ -523,7 +515,7 @@ namespace BLL
...
@@ -523,7 +515,7 @@ namespace BLL
aMatch
.
Angle
=
(
int
)
code
[
0
].
Angle
;
aMatch
.
Angle
=
(
int
)
code
[
0
].
Angle
;
aMatch
.
CodeType
=
code
[
0
].
CodeType
;
aMatch
.
CodeType
=
code
[
0
].
CodeType
;
}
}
return
true
;
return
true
&&
!
匹配冲突
;
}
}
else
else
{
{
...
@@ -795,7 +787,10 @@ namespace BLL
...
@@ -795,7 +787,10 @@ namespace BLL
continue
;
continue
;
MatchAnalysis
.
MatchResult
(
codeMatch
[
i
].
Keyword
,
true
);
MatchAnalysis
.
MatchResult
(
codeMatch
[
i
].
Keyword
,
true
);
if
(
key
.
ContainsKey
(
codeMatch
[
i
].
Keyword
))
if
(
key
.
ContainsKey
(
codeMatch
[
i
].
Keyword
))
{
LogNet
.
log
.
Info
(
$
"匹配冲突 [{codeMatch[i].Keyword}], {key[codeMatch[i].Keyword]} != {filtercode}"
);
key
[
codeMatch
[
i
].
Keyword
]
=
filtercode
.
Trim
();
key
[
codeMatch
[
i
].
Keyword
]
=
filtercode
.
Trim
();
}
else
else
key
.
Add
(
codeMatch
[
i
].
Keyword
,
filtercode
.
Trim
());
key
.
Add
(
codeMatch
[
i
].
Keyword
,
filtercode
.
Trim
());
if
(
codeMatch
[
i
].
Characteristic
)
if
(
codeMatch
[
i
].
Characteristic
)
...
...
SmartScan/ScanWork.cs
查看文件 @
f9bd059
...
@@ -316,7 +316,7 @@ namespace SmartScan
...
@@ -316,7 +316,7 @@ namespace SmartScan
{
{
string
url
=
config
.
HttpLabelReport
.
Trim
();
string
url
=
config
.
HttpLabelReport
.
Trim
();
if
(
string
.
IsNullOrWhiteSpace
(
url
))
if
(
string
.
IsNullOrWhiteSpace
(
url
)
&&
!
url
.
ToLower
().
StartsWith
(
"http"
)
)
return
true
;
return
true
;
var
keylist
=
matchedTexts
.
Select
(
x
=>
new
{
Content
=
x
}).
ToList
();
var
keylist
=
matchedTexts
.
Select
(
x
=>
new
{
Content
=
x
}).
ToList
();
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论