Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit b0d7eb6e
由
sunke
编写于
2022-09-28 16:01:49 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
完善Neotel接口
1 个父辈
7346b73b
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
176 行增加
和
5 行删除
src/main/java/com/neotel/smfcore/core/barcode/bean/BarcodeRule.java
src/main/java/com/neotel/smfcore/custom/neotel/NeotelApi.java
src/main/java/com/neotel/smfcore/core/barcode/bean/BarcodeRule.java
查看文件 @
b0d7eb6
...
@@ -449,8 +449,10 @@ public class BarcodeRule {
...
@@ -449,8 +449,10 @@ public class BarcodeRule {
}
}
}
}
public
CodeBean
toCodeBean
(
String
codeStr
){
/**
log
.
info
(
"开始解析条码["
+
codeStr
+
"]"
);
* 从条码中解析尺寸和条码
*/
public
static
CodeBean
splitCodeAndSize
(
String
codeStr
){
CodeBean
codeBean
=
new
CodeBean
();
CodeBean
codeBean
=
new
CodeBean
();
codeBean
.
setCodeStr
(
codeStr
);
codeBean
.
setCodeStr
(
codeStr
);
//是否带有位置信息
//是否带有位置信息
...
@@ -499,6 +501,61 @@ public class BarcodeRule {
...
@@ -499,6 +501,61 @@ public class BarcodeRule {
}
}
codeBean
.
setCodeStr
(
codeStr
);
codeBean
.
setCodeStr
(
codeStr
);
return
codeBean
;
}
public
CodeBean
toCodeBean
(
String
codeStr
){
log
.
info
(
"开始解析条码["
+
codeStr
+
"]"
);
CodeBean
codeBean
=
splitCodeAndSize
(
codeStr
);
// CodeBean codeBean = new CodeBean();
// codeBean.setCodeStr(codeStr);
// //是否带有位置信息
// float locationX = -1f;
// float locationY = -1f;
// int reelWidth = -1;
// int reelHeight = -1;
// //=摄像头编号+条码X坐标x条码Y坐标-料盘尺寸=CODE
// //=1+123.4x100.5-7x12=CODE或者7x12=CODE
// if(codeStr.startsWith("=") && codeStr.contains("x")){
// codeStr = codeStr.substring(1);
// String[] arr = codeStr.split("=", 2);
// String sizeStr = arr[0];
// if(sizeStr.contains("+") && sizeStr.contains("-")){
// String[] locationSizeArr = sizeStr.split("-",2);
// //尺寸信息
// sizeStr = locationSizeArr[1];
//
// String[] locationInfoArr = locationSizeArr[0].split("\\+");
// String cameraIndexStr = locationInfoArr[0];
// //摄像头编号信息
// int cameraIndex = Integer.valueOf(cameraIndexStr);
//
// codeBean.setCameraIndex(cameraIndex);
//
// String locationStr = locationInfoArr[1];
//
// //带有位置信息
// String[] locationArr = locationStr.split("x");
// locationX = Float.valueOf(locationArr[0].trim());
// locationY = Float.valueOf(locationArr[1].trim());
// }
//
// //带有料盘宽高信息
// if(!Strings.isNullOrEmpty(sizeStr)){
// String[] sizeInfoArr = sizeStr.split("x",2);
// reelWidth = Integer.parseInt(sizeInfoArr[0].trim());
// reelHeight = Integer.parseInt(sizeInfoArr[1].trim());
// }
//
// codeBean.setLocationX(locationX);
// codeBean.setLocationY(locationY);
// codeBean.setReelWidth(reelWidth);
// codeBean.setReelHeight(reelHeight);
// codeStr = arr[1];
//
// }
// codeBean.setCodeStr(codeStr);
if
(!
isValidRule
()){
if
(!
isValidRule
()){
codeBean
.
setError
(
"smfcore.error.barcode.noRule"
,
"解析规则未定义"
);
codeBean
.
setError
(
"smfcore.error.barcode.noRule"
,
"解析规则未定义"
);
return
codeBean
;
return
codeBean
;
...
@@ -597,8 +654,8 @@ public class BarcodeRule {
...
@@ -597,8 +654,8 @@ public class BarcodeRule {
b
.
setProduceDate
(
produceDate
);
b
.
setProduceDate
(
produceDate
);
b
.
setExpireDate
(
expireDate
);
b
.
setExpireDate
(
expireDate
);
b
.
setProvider
(
supplier
);
b
.
setProvider
(
supplier
);
b
.
setPlateSize
(
reelWidth
);
b
.
setPlateSize
(
codeBean
.
getReelWidth
()
);
b
.
setHeight
(
reelHeight
);
b
.
setHeight
(
codeBean
.
getReelHeight
()
);
b
.
setMsl
(
msl
);
b
.
setMsl
(
msl
);
codeBean
.
setBarcode
(
b
);
codeBean
.
setBarcode
(
b
);
...
...
src/main/java/com/neotel/smfcore/custom/neotel/NeotelApi.java
查看文件 @
b0d7eb6
...
@@ -5,9 +5,15 @@ import com.neotel.smfcore.common.utils.DateUtil;
...
@@ -5,9 +5,15 @@ import com.neotel.smfcore.common.utils.DateUtil;
import
com.neotel.smfcore.common.utils.HttpHelper
;
import
com.neotel.smfcore.common.utils.HttpHelper
;
import
com.neotel.smfcore.common.utils.JsonUtil
;
import
com.neotel.smfcore.common.utils.JsonUtil
;
import
com.neotel.smfcore.core.api.bean.ApiResult
;
import
com.neotel.smfcore.core.api.bean.ApiResult
;
import
com.neotel.smfcore.core.api.bean.CodeValidateParam
;
import
com.neotel.smfcore.core.api.listener.BaseSmfApiListener
;
import
com.neotel.smfcore.core.api.listener.BaseSmfApiListener
;
import
com.neotel.smfcore.core.barcode.bean.BarcodeRule
;
import
com.neotel.smfcore.core.barcode.bean.CodeBean
;
import
com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE
;
import
com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE
;
import
com.neotel.smfcore.core.barcode.service.manager.IComponentManager
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.barcode.service.po.Component
;
import
com.neotel.smfcore.core.barcode.utils.CodeResolve
;
import
com.neotel.smfcore.core.order.service.manager.ILiteOrderItemManager
;
import
com.neotel.smfcore.core.order.service.manager.ILiteOrderItemManager
;
import
com.neotel.smfcore.core.order.service.po.LiteOrder
;
import
com.neotel.smfcore.core.order.service.po.LiteOrder
;
import
com.neotel.smfcore.core.order.service.po.LiteOrderItem
;
import
com.neotel.smfcore.core.order.service.po.LiteOrderItem
;
...
@@ -30,6 +36,12 @@ public class NeotelApi extends BaseSmfApiListener {
...
@@ -30,6 +36,12 @@ public class NeotelApi extends BaseSmfApiListener {
@Autowired
@Autowired
private
ILiteOrderItemManager
liteOrderItemManager
;
private
ILiteOrderItemManager
liteOrderItemManager
;
@Autowired
private
CodeResolve
codeResolve
;
@Autowired
private
IComponentManager
componentManager
;
@Override
@Override
public
boolean
isForThisApi
(
String
apiName
)
{
public
boolean
isForThisApi
(
String
apiName
)
{
return
apiName
!=
null
&&
apiName
.
equalsIgnoreCase
(
"neotel"
);
return
apiName
!=
null
&&
apiName
.
equalsIgnoreCase
(
"neotel"
);
...
@@ -112,7 +124,7 @@ public class NeotelApi extends BaseSmfApiListener {
...
@@ -112,7 +124,7 @@ public class NeotelApi extends BaseSmfApiListener {
}
}
}
}
private
String
getData
(
Map
<
String
,
Object
>
dataMap
,
String
dataKey
)
{
private
static
String
getData
(
Map
<
String
,
Object
>
dataMap
,
String
dataKey
)
{
Object
data
=
dataMap
.
get
(
dataKey
);
Object
data
=
dataMap
.
get
(
dataKey
);
if
(
data
==
null
)
{
if
(
data
==
null
)
{
return
""
;
return
""
;
...
@@ -121,6 +133,108 @@ public class NeotelApi extends BaseSmfApiListener {
...
@@ -121,6 +133,108 @@ public class NeotelApi extends BaseSmfApiListener {
}
}
}
}
// public static void main(String[] args) {
// CodeValidateParam param = new CodeValidateParam("","","","=7x8=SU300PH51CM","");
// testcanPutInBeforeResolve("http://211.144.80.100:2000/EIMS/EIMSAPI/SMF_GetInRequest_MaterialInfo",param);
// }
@Override
public
Barcode
canPutInBeforeResolve
(
String
inCheckUrl
,
CodeValidateParam
params
)
throws
ValidateException
{
try
{
CodeBean
codeBean
=
BarcodeRule
.
splitCodeAndSize
(
params
.
getCode
());
String
reelId
=
codeBean
.
getCodeStr
();
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"reelId"
,
reelId
);
paramMap
.
put
(
"fullCode"
,
reelId
);
log
.
info
(
reelId
+
"入库验证,参数"
+
JsonUtil
.
toJsonStr
(
paramMap
));
String
result
=
HttpHelper
.
postJson
(
inCheckUrl
,
paramMap
);
System
.
out
.
println
(
result
);
log
.
info
(
reelId
+
"入库验证返回"
+
result
);
ApiResult
apiResult
=
JsonUtil
.
toObj
(
result
,
ApiResult
.
class
);
if
(
apiResult
.
getCode
()
==
0
)
{
Map
<
String
,
Object
>
dataMap
=
(
Map
<
String
,
Object
>)
apiResult
.
getData
();
Barcode
barcode
=
new
Barcode
();
String
mesReelId
=
getData
(
dataMap
,
"reelId"
);
if
(
Strings
.
isNotBlank
(
mesReelId
))
{
Barcode
dbBarcode
=
barcodeManager
.
findByBarcode
(
mesReelId
);
if
(
dbBarcode
!=
null
){
barcode
=
dbBarcode
;
}
barcode
.
setBarcode
(
mesReelId
);
}
barcode
.
setPlateSize
(
codeBean
.
getReelWidth
());
barcode
.
setHeight
(
codeBean
.
getReelHeight
());
String
partNum
=
getData
(
dataMap
,
"partNum"
);
if
(
Strings
.
isNotBlank
(
partNum
))
{
barcode
.
setPartNumber
(
partNum
);
}
else
{
barcode
.
setPartNumber
(
mesReelId
);
}
String
vendor
=
getData
(
dataMap
,
"vendor"
);
if
(
Strings
.
isNotBlank
(
vendor
))
{
barcode
.
setProvider
(
vendor
);
}
String
qtyStr
=
getData
(
dataMap
,
"qty"
);
if
(
Strings
.
isNotBlank
(
qtyStr
))
{
int
qty
=
Integer
.
valueOf
(
qtyStr
);
if
(
qty
>
0
)
{
barcode
.
setAmount
(
qty
);
}
}
String
batch
=
getData
(
dataMap
,
"batch"
);
if
(
Strings
.
isNotBlank
(
batch
))
{
barcode
.
setBatch
(
batch
);
}
try
{
String
produceDateStr
=
getData
(
dataMap
,
"produceDate"
);
if
(
Strings
.
isNotBlank
(
produceDateStr
))
{
Date
produceDate
=
DateUtil
.
toDate
(
produceDateStr
,
"yyyy-MM-dd HH:mm:ss"
);
barcode
.
setProduceDate
(
produceDate
);
}
}
catch
(
ParseException
e
)
{
log
.
error
(
"日期转换出错"
,
e
);
}
resolveComponent
(
barcode
);
barcode
=
barcodeManager
.
saveBarcode
(
barcode
);
return
barcode
;
}
else
{
return
null
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"入库验证接口出错:"
+
e
.
getMessage
());
throw
new
ValidateException
(
"smfcore.mesApi.inCheck.error"
,
"MES验证出错:"
+
e
.
getMessage
());
}
}
private
Component
resolveComponent
(
Barcode
barcode
){
Component
component
=
componentManager
.
findByPartNumberAndProvider
(
barcode
.
getPartNumber
(),
barcode
.
getProvider
());
if
(
component
==
null
){
log
.
info
(
"自动添加["
+
barcode
.
getPartNumber
()+
"]["
+
barcode
.
getProvider
()+
"]的档案信息"
);
component
=
new
Component
();
component
.
setPartNumber
(
barcode
.
getPartNumber
());
component
.
setAmount
(
barcode
.
getAmount
());
int
w
=
barcode
.
getPlateSize
();
int
h
=
barcode
.
getHeight
();
component
.
setPlateSize
(
w
);
component
.
setHeight
(
h
);
component
.
setProvider
(
barcode
.
getProvider
());
component
=
componentManager
.
save
(
component
);
}
return
component
;
}
/**
/**
* 入库判定
* 入库判定
*
*
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论