Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit cdb1f9c7
由
zshaohui
编写于
2025-10-17 11:29:52 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1.1560条码解析提交
1 个父辈
3be908f0
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
124 行增加
和
0 行删除
src/main/java/com/neotel/smfcore/custom/haier1560/Haier1560Api.java
src/main/java/com/neotel/smfcore/custom/haier1560/Haier1560Api.java
0 → 100644
查看文件 @
cdb1f9c
package
com
.
neotel
.
smfcore
.
custom
.
haier1560
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.DateUtil
;
import
com.neotel.smfcore.common.utils.StringUtils
;
import
com.neotel.smfcore.core.api.bean.CodeValidateParam
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.order.service.po.LiteOrder
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.custom.neotel.NeotelApi
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
@Component
public
class
Haier1560Api
extends
NeotelApi
{
@Override
public
boolean
isForThisApi
(
String
apiName
)
{
return
apiName
!=
null
&&
apiName
.
equalsIgnoreCase
(
"haier1560"
);
}
@Override
public
void
inTaskStatusChange
(
String
inNotifyUrl
,
DataLog
task
)
{
super
.
inTaskStatusChange
(
inNotifyUrl
,
task
);
}
@Override
public
void
outTaskStatusChange
(
String
outNotifyUrl
,
DataLog
task
)
{
super
.
outTaskStatusChange
(
outNotifyUrl
,
task
);
}
@Override
public
Barcode
canPutInBeforeResolve
(
String
codeResolveUrl
,
CodeValidateParam
params
)
throws
ValidateException
{
String
code
=
params
.
getCode
();
Barcode
barcode
=
barcodeManager
.
findByBarcode
(
code
);
if
(
barcode
==
null
)
{
barcode
=
new
Barcode
();
}
barcode
.
setBarcode
(
code
);
barcode
.
setFullCode
(
code
);
barcode
.
setHeight
(
1
);
barcode
.
setPlateSize
(
1
);
//开始解析条码信息
if
(!
code
.
startsWith
(
"ID"
))
{
throw
new
ValidateException
(
"smfcore.error.barcode.noValidCode"
,
"无效的条码"
);
}
//截取前2位
String
remaining
=
code
.
substring
(
2
);
//获取到P的坐标
int
pnStartIndex
=
remaining
.
indexOf
(
"P"
);
if
(
pnStartIndex
==
-
1
)
{
throw
new
ValidateException
(
"smfcore.error.barcode.noField"
,
"条码解析失败,未找到{0}字段"
,
new
String
[]{
"Vendor Code"
});
}
//解析到供应商信息
String
vendorCode
=
remaining
.
substring
(
0
,
pnStartIndex
);
if
(
StringUtils
.
isEmpty
(
vendorCode
))
{
throw
new
ValidateException
(
"smfcore.error.barcode.noField"
,
"条码解析失败,未找到{0}字段"
,
new
String
[]{
"Vendor Code"
});
}
barcode
.
setProvider
(
vendorCode
);
//开始解析PartNumber
remaining
=
remaining
.
substring
(
pnStartIndex
+
1
);
//获取到DC的坐标
int
dcStartIndex
=
remaining
.
indexOf
(
"DC"
);
if
(
dcStartIndex
==
-
1
){
throw
new
ValidateException
(
"smfcore.error.barcode.noField"
,
"条码解析失败,未找到{0}字段"
,
new
String
[]{
"PartNumber"
});
}
String
partNumber
=
remaining
.
substring
(
0
,
dcStartIndex
);
if
(
StringUtils
.
isEmpty
(
partNumber
)){
throw
new
ValidateException
(
"smfcore.error.barcode.noField"
,
"条码解析失败,未找到{0}字段"
,
new
String
[]{
"PartNumber"
});
}
barcode
.
setPartNumber
(
partNumber
);
//开始解析生产日期
remaining
=
remaining
.
substring
(
dcStartIndex
+
2
);
int
qStartIndex
=
remaining
.
indexOf
(
"Q"
);
if
(
qStartIndex
==
-
1
){
throw
new
ValidateException
(
"smfcore.error.barcode.noField"
,
"条码解析失败,未找到{0}字段"
,
new
String
[]{
"Production Date"
});
}
String
dc
=
remaining
.
substring
(
0
,
qStartIndex
);
if
(
StringUtils
.
isEmpty
(
dc
)
||
dc
.
length
()
<
6
){
throw
new
ValidateException
(
"smfcore.error.barcode.noField"
,
"条码解析失败,未找到{0}字段"
,
new
String
[]{
"Production Date"
});
}
dc
=
dc
.
substring
(
0
,
6
);
Date
produceDate
=
DateUtil
.
toDate
(
dc
,
"yyMMdd"
);
barcode
.
setProduceDate
(
produceDate
);
//开始解析数量
remaining
=
remaining
.
substring
(
qStartIndex
+
1
);
int
lcStartIndex
=
remaining
.
indexOf
(
"LC"
);
if
(
lcStartIndex
==
-
1
)
{
throw
new
ValidateException
(
"smfcore.error.barcode.noField"
,
"条码解析失败,未找到{0}字段"
,
new
String
[]{
"Quantity"
});
}
String
qtyStr
=
remaining
.
substring
(
0
,
lcStartIndex
);
if
(
StringUtils
.
isEmpty
(
qtyStr
)){
throw
new
ValidateException
(
"smfcore.error.barcode.noField"
,
"条码解析失败,未找到{0}字段"
,
new
String
[]{
"Quantity"
});
}
int
qty
=
Integer
.
parseInt
(
qtyStr
);
barcode
.
setAmount
(
qty
);
//开始解析LC
String
batch
=
remaining
.
substring
(
lcStartIndex
+
2
);
if
(
StringUtils
.
isEmpty
(
batch
)){
throw
new
ValidateException
(
"smfcore.error.barcode.noField"
,
"条码解析失败,未找到{0}字段"
,
new
String
[]{
"Batch Number"
});
}
barcode
.
setBatch
(
batch
);
return
barcode
;
//smfcore.error.barcode.noField=条码解析失败,未找到{0}字段
//return super.canPutInBeforeResolve(codeResolveUrl, params);
}
@Override
public
Barcode
canPutInAfterResolve
(
String
inCheckUrl
,
CodeValidateParam
params
,
Barcode
barcode
)
throws
ValidateException
{
return
super
.
canPutInAfterResolve
(
inCheckUrl
,
params
,
barcode
);
}
@Override
public
void
onOrderStatusChange
(
String
orderNotifyUrl
,
LiteOrder
liteOrder
)
{
super
.
onOrderStatusChange
(
orderNotifyUrl
,
liteOrder
);
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论