Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 72bf5392
由
LN
编写于
2022-05-25 11:26:30 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
西门子接口修改。
1 个父辈
135702d7
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
243 行增加
和
22 行删除
src/main/java/com/neotel/smfcore/common/utils/JsonUtil.java
src/main/java/com/neotel/smfcore/core/device/handler/impl/BaseDeviceHandler.java
src/main/java/com/neotel/smfcore/core/device/handler/impl/MimoBoxHandler.java
src/main/java/com/neotel/smfcore/core/storage/rest/StoragePosController.java
src/main/java/com/neotel/smfcore/siemens/SiemensApi.java
src/main/java/com/neotel/smfcore/common/utils/JsonUtil.java
0 → 100644
查看文件 @
72bf539
package
com
.
neotel
.
smfcore
.
common
.
utils
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.JavaType
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Slf4j
public
class
JsonUtil
{
// 定义jackson对象
private
static
final
ObjectMapper
MAPPER
=
new
ObjectMapper
();
static
{
MAPPER
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
}
/**
* 将对象转换成json字符串。
* <p>Title: pojoToJson</p>
* <p>Description: </p>
* @param data
* @return
*/
public
static
String
toJsonStr
(
Object
data
)
{
try
{
String
string
=
MAPPER
.
writeValueAsString
(
data
);
return
string
;
}
catch
(
Exception
e
)
{
log
.
info
(
"转换JSON字符串出错:"
,
e
);
}
return
null
;
}
/**
* 将json结果集转化为对象
*
* @param jsonStr json数据
* @param beanType 对象中的object类型
* @return
*/
public
static
<
T
>
T
toObj
(
String
jsonStr
,
Class
<
T
>
beanType
)
{
try
{
T
t
=
MAPPER
.
readValue
(
jsonStr
,
beanType
);
return
t
;
}
catch
(
Exception
e
)
{
log
.
info
(
jsonStr
+
"转换对象出错:"
,
e
);
}
return
null
;
}
/**
* 将json数据转换成对象list
* <p>Title: jsonToList</p>
* <p>Description: </p>
* @param jsonStr
* @param beanType
* @return
*/
public
static
<
T
>
List
<
T
>
toList
(
String
jsonStr
,
Class
<
T
>
beanType
)
{
JavaType
javaType
=
MAPPER
.
getTypeFactory
().
constructParametricType
(
List
.
class
,
beanType
);
try
{
List
<
T
>
list
=
MAPPER
.
readValue
(
jsonStr
,
javaType
);
return
list
;
}
catch
(
Exception
e
)
{
log
.
info
(
jsonStr
+
"转换List出错:"
,
e
);
}
return
new
ArrayList
<>();
}
public
static
Map
<
String
,
Object
>
toMap
(
String
jsonStr
){
//JavaType javaType = MAPPER.getTypeFactory().constructParametricType(HashMap.class, String.class, String.class);
try
{
//Map<String, String> map = MAPPER.readValue(jsonStr, javaType);
Map
<
String
,
Object
>
map
=
MAPPER
.
readValue
(
jsonStr
,
Map
.
class
);
return
map
;
}
catch
(
Exception
e
)
{
log
.
info
(
jsonStr
+
"转换Map出错:"
,
e
);
}
return
new
HashMap
<>();
}
public
static
void
main
(
String
args
[])
throws
Exception
{
String
jsonStr
=
"[{\n"
+
" \"action\": \"补料\",\n"
+
" \"hSerial\": \"82\",\n"
+
" \"so\": \"879235\",\n"
+
"\"refno\": \"F001_879235N_1\",\n"
+
"\"partNum\": \"7H.47134.1F1\",\n"
+
" \"slot\": \"1-11\",\n"
+
"\"qty\": \"2006\",\n"
+
"\"facility\": \"SU\",\n"
+
"\"sdte\": \"20191118\",\n"
+
"\"stme\": \"85957\",\n"
+
"\"reelcut\": \"N\",\n"
+
"\"mdte\": \"20191115\",\n"
+
"\"mtme\": \"172238\"\n"
+
"},\n{\n"
+
" \"action\": \"补料\",\n"
+
" \"hSerial\": \"82\",\n"
+
" \"so\": \"879235\",\n"
+
"\"refno\": \"F001_879235N_1\",\n"
+
"\"partNum\": \"7H.47134.1F1\",\n"
+
" \"slot\": \"1-11\",\n"
+
"\"qty\": \"2006\",\n"
+
"\"facility\": \"SU\",\n"
+
"\"sdte\": \"20191118\",\n"
+
"\"stme\": \"85957\",\n"
+
"\"reelcut\": \"N\",\n"
+
"\"mdte\": \"20191115\",\n"
+
"\"mtme\": \"172238\"\n"
+
"}\n]"
;
// List<RequestOutItemBean> items = JsonUtil.toList(jsonStr, RequestOutItemBean.class);
// for (RequestOutItemBean item : items) {
// System.out.println(item);
// }
// System.out.println(DateUtil.toDateString(new Date(),"yyyyMMddHHmmssS"));
// System.out.println(DateUtil.toDateString(new Date(),"yyyyMMddHHmmssS"));
// System.out.println(DateUtil.toDateString(new Date(),"yyyyMMddHHmmssS"));
// System.out.println(DateUtil.toDateString(new Date(),"yyyyMMddHHmmssS"));
//
// System.out.println(System.nanoTime());
// System.out.println(System.nanoTime());
// System.out.println(System.currentTimeMillis());
// System.out.println(System.currentTimeMillis());
jsonStr
=
"{\"state\":\"0\",\"msg\":\"鏂欏嵎浣嶆暟涓嶅尮閰??\",\"info\":{\"so\":\"\",\"facility\":\"12334\",\"company\":\"\",\"qty\":\"\",\"soseq\":\"\"}}"
;
jsonStr
=
"{\"data\":[{\"Serial\":\"58890\",\"VehicleID\":\"D15\",\"Status\":\"\"},{\"Serial\":\"58890\",\"VehicleID\":\"D44\",\"Status\":\"\"},{\"Serial\":\"58890\",\"VehicleID\":\"D83\",\"Status\":\"\"},{\"Serial\":\"58890\",\"VehicleID\":\"D90\",\"Status\":\"\"},{\"Serial\":\"58890\",\"VehicleID\":\"D98\",\"Status\":\"\"}]}"
;
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
jsonStr
);
Object
data
=
map
.
get
(
"data"
);
if
(
data
!=
null
){
List
<
Object
>
dataList
=
(
List
)
data
;
for
(
Object
info
:
dataList
)
{
Map
<
String
,
String
>
infoMap
=
(
Map
)
info
;
System
.
out
.
println
(
infoMap
.
get
(
"Serial"
));
}
}
}
}
src/main/java/com/neotel/smfcore/core/device/handler/impl/BaseDeviceHandler.java
查看文件 @
72bf539
...
@@ -251,11 +251,11 @@ public class BaseDeviceHandler implements IDeviceHandler {
...
@@ -251,11 +251,11 @@ public class BaseDeviceHandler implements IDeviceHandler {
barcodeSave
=
codeResolve
.
resolveOneValideBarcode
(
codeStr
,
type
);
barcodeSave
=
codeResolve
.
resolveOneValideBarcode
(
codeStr
,
type
);
}
}
//西门子接口验证
//
//西门子接口验证
boolean
result
=
SiemensApi
.
getMaterialLot
(
1
,
storage
.
getId
(),
storage
.
getName
(),
barcodeSave
.
getBarcode
());
//
boolean result=SiemensApi.getMaterialLot(1, storage.getId(),storage.getName(),barcodeSave.getBarcode());
if
(!
result
)
{
//
if(!result) {
throw
new
ValidateException
(
"smfcore.error.getMaterialLot.in"
,
"条码[{0}]验证失败,无法入库"
,
new
String
[]{
barcodeSave
.
getBarcode
()});
//
throw new ValidateException("smfcore.error.getMaterialLot.in", "条码[{0}]验证失败,无法入库", new String[]{barcodeSave.getBarcode()});
}
//
}
//查找库位,生成入库任务
//查找库位,生成入库任务
DataLog
putInTask
=
generatePutInTask
(
statusBean
,
barcodeSave
,
storage
);
DataLog
putInTask
=
generatePutInTask
(
statusBean
,
barcodeSave
,
storage
);
...
@@ -658,8 +658,8 @@ public class BaseDeviceHandler implements IDeviceHandler {
...
@@ -658,8 +658,8 @@ public class BaseDeviceHandler implements IDeviceHandler {
task
.
setStatus
(
OP_STATUS
.
FINISHED
.
name
());
task
.
setStatus
(
OP_STATUS
.
FINISHED
.
name
());
taskService
.
updateFinishedTask
(
task
);
taskService
.
updateFinishedTask
(
task
);
//调用西门子接口
//
//调用西门子接口
SiemensApi
.
processMaterialLot
(
1
,
storagePos
.
getStorageId
(),
task
.
getStorageName
(),
barcode
.
getBarcode
()
);
// SiemensApi.lotInOut(barcode.getBarcode(),1
);
}
}
...
@@ -708,8 +708,8 @@ public class BaseDeviceHandler implements IDeviceHandler {
...
@@ -708,8 +708,8 @@ public class BaseDeviceHandler implements IDeviceHandler {
//更新缓存中的库存信息
//更新缓存中的库存信息
dataCache
.
updateInventory
(
storagePos
,
barcode
);
dataCache
.
updateInventory
(
storagePos
,
barcode
);
//
调用西门子接口
//
调用西门子接口
SiemensApi
.
processMaterialLot
(
2
,
storagePos
.
getStorageId
(),
task
.
getStorageName
(),
barcode
.
getBarcode
()
);
// SiemensApi.lotInOut(barcode.getBarcode(),2
);
//记录日志
//记录日志
task
.
setStatus
(
OP_STATUS
.
FINISHED
.
name
());
task
.
setStatus
(
OP_STATUS
.
FINISHED
.
name
());
...
...
src/main/java/com/neotel/smfcore/core/device/handler/impl/MimoBoxHandler.java
查看文件 @
72bf539
...
@@ -125,11 +125,11 @@ public class MimoBoxHandler extends BaseDeviceHandler {
...
@@ -125,11 +125,11 @@ public class MimoBoxHandler extends BaseDeviceHandler {
throw
new
ValidateException
(
"smfcore.error.mimo.outFial"
,
"未找到可出库的物料"
,
new
String
[]{
storageId
});
throw
new
ValidateException
(
"smfcore.error.mimo.outFial"
,
"未找到可出库的物料"
,
new
String
[]{
storageId
});
}
else
{
}
else
{
//西门子接口验证
//
//西门子接口验证
boolean
result
=
SiemensApi
.
getMaterialLot
(
2
,
storage
.
getId
(),
storage
.
getName
(),
pos
.
getBarcode
().
getBarcode
());
//
boolean result= SiemensApi.getMaterialLot(2, storage.getId(),storage.getName(),pos.getBarcode().getBarcode());
if
(!
result
)
{
//
if(!result) {
throw
new
ValidateException
(
"smfcore.error.getMaterialLot.out"
,
"条码[{0}]验证失败,无法出库"
,
new
String
[]{
pos
.
getBarcode
().
getBarcode
()});
//
throw new ValidateException("smfcore.error.getMaterialLot.out", "条码[{0}]验证失败,无法出库", new String[]{pos.getBarcode().getBarcode()});
}
//
}
log
.
info
(
"根据PN单盘出库:【"
+
storage
.
getName
()
+
"_"
+
storage
.
getCid
()
+
"】位置仓位【"
+
pos
.
getPosName
()
+
"】"
);
log
.
info
(
"根据PN单盘出库:【"
+
storage
.
getName
()
+
"_"
+
storage
.
getCid
()
+
"】位置仓位【"
+
pos
.
getPosName
()
+
"】"
);
String
outResult
=
taskService
.
checkout
(
storage
,
pos
,
true
,
SecurityUtils
.
getCurrentUsername
());
String
outResult
=
taskService
.
checkout
(
storage
,
pos
,
true
,
SecurityUtils
.
getCurrentUsername
());
...
...
src/main/java/com/neotel/smfcore/core/storage/rest/StoragePosController.java
查看文件 @
72bf539
...
@@ -346,11 +346,11 @@ public class StoragePosController {
...
@@ -346,11 +346,11 @@ public class StoragePosController {
// throw new ValidateException("料仓[" + pos.getStorageId() + "]不存在");
// throw new ValidateException("料仓[" + pos.getStorageId() + "]不存在");
}
}
//西门子接口验证
//
//西门子接口验证
boolean
result
=
SiemensApi
.
getMaterialLot
(
2
,
storage
.
getId
(),
storage
.
getName
(),
pos
.
getBarcode
().
getBarcode
());
//
boolean result=SiemensApi.getMaterialLot(2, storage.getId(),storage.getName(),pos.getBarcode().getBarcode());
if
(!
result
)
{
//
if(!result) {
throw
new
ValidateException
(
"smfcore.error.getMaterialLot.out"
,
"条码[{0}]验证失败,无法出库"
,
new
String
[]{
pos
.
getBarcode
().
getBarcode
()});
//
throw new ValidateException("smfcore.error.getMaterialLot.out", "条码[{0}]验证失败,无法出库", new String[]{pos.getBarcode().getBarcode()});
}
//
}
log
.
info
(
"出库料仓【"
+
storage
.
getName
()
+
"_"
+
storage
.
getCid
()
+
"】位置仓位【"
+
pos
.
getPosName
()
+
"】"
);
log
.
info
(
"出库料仓【"
+
storage
.
getName
()
+
"_"
+
storage
.
getCid
()
+
"】位置仓位【"
+
pos
.
getPosName
()
+
"】"
);
String
outResult
=
taskService
.
checkout
(
storage
,
pos
,
isSingleOut
,
SecurityUtils
.
getCurrentUsername
());
String
outResult
=
taskService
.
checkout
(
storage
,
pos
,
isSingleOut
,
SecurityUtils
.
getCurrentUsername
());
...
...
src/main/java/com/neotel/smfcore/siemens/SiemensApi.java
查看文件 @
72bf539
package
com
.
neotel
.
smfcore
.
siemens
;
package
com
.
neotel
.
smfcore
.
siemens
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.utils.HttpHelper
;
import
com.neotel.smfcore.common.utils.JsonUtil
;
import
com.neotel.smfcore.common.utils.XmlUtil
;
import
com.neotel.smfcore.common.utils.XmlUtil
;
import
com.neotel.smfcore.core.system.listener.ITaskListener
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.siemens.util.WSClientUtil
;
import
com.neotel.smfcore.siemens.util.WSClientUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.Map
;
@Slf4j
@Slf4j
@Component
@Component
public
class
SiemensApi
{
public
class
SiemensApi
implements
ITaskListener
{
private
static
SiemensConfig
config
;
private
static
SiemensConfig
config
;
@Autowired
@Autowired
public
void
setConfig
(
SiemensConfig
config
){
public
void
setConfig
(
SiemensConfig
config
){
SiemensApi
.
config
=
config
;
SiemensApi
.
config
=
config
;
}
}
public
static
boolean
getMaterialLot
(
int
inoutType
,
String
storageId
,
String
storageName
,
String
materialLot
){
@Override
public
void
onTaskStatusChange
(
DataLog
task
)
{
if
(
task
.
isFinished
()){
if
(
task
.
isPutInTask
()){
SiemensApi
.
lotInOut
(
task
.
getBarcode
(),
1
);
}
else
{
SiemensApi
.
lotInOut
(
task
.
getBarcode
(),
2
);
}
}
}
public
static
boolean
lotInOut
(
String
lot
,
int
inoutType
)
{
if
(
ObjectUtil
.
isEmpty
(
config
.
url
))
{
log
.
info
(
"没有配置Siemens,无需通知"
);
return
true
;
}
String
action
=
"IN"
;
if
(
inoutType
==
2
)
{
action
=
"OUT"
;
}
log
.
info
(
"Siemens["
+
config
.
url
+
"]:料盘["
+
lot
+
"]["
+
action
+
"]完成"
);
try
{
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
params
.
put
(
"LotID"
,
lot
);
params
.
put
(
"ACTION"
,
inoutType
);
String
result
=
HttpHelper
.
postJson
(
config
.
url
,
params
);
log
.
info
(
"Siemens["
+
config
.
url
+
"]返回料盘["
+
lot
+
"]的["
+
action
+
"]结果:"
+
result
);
Map
<
String
,
Object
>
returnMap
=
JsonUtil
.
toMap
(
result
);
if
(
returnMap
!=
null
&&
returnMap
.
containsKey
(
"Status"
))
{
boolean
res
=
Boolean
.
parseBoolean
(
returnMap
.
get
(
"Status"
).
toString
());
return
res
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"Siemens["
+
config
.
url
+
"]:料盘["
+
lot
+
"]["
+
action
+
"]完成 出错:"
,
e
);
}
return
false
;
// lot进tower:
// {
// "LotID": "M03289629",
// "ACTION": "IN"
// }
//
// Lot出tower:
// {
// "LotID": "M03289629",
// "ACTION": "OUT"
// }
// 返回的信息:
// 进出无问题如下:
// {
// "Status": true,
// "Message": "OK",
// "Data": null
// }
//
// 检查数据存在一定逻辑错误而无法成功存取的返回信息如下:
// {
// "Status": false,
// "Message": "NG",
// "Data": null
// }
}
private
static
boolean
getMaterialLot
(
int
inoutType
,
String
storageId
,
String
storageName
,
String
materialLot
){
if
(
ObjectUtil
.
isEmpty
(
config
.
url
)){
if
(
ObjectUtil
.
isEmpty
(
config
.
url
)){
return
true
;
return
true
;
...
@@ -71,7 +146,7 @@ public class SiemensApi {
...
@@ -71,7 +146,7 @@ public class SiemensApi {
}
}
p
ublic
static
boolean
processMaterialLot
(
int
inoutType
,
String
storageId
,
String
storageName
,
String
materialLot
){
p
rivate
static
boolean
processMaterialLot
(
int
inoutType
,
String
storageId
,
String
storageName
,
String
materialLot
){
if
(
ObjectUtil
.
isEmpty
(
config
.
url
)){
if
(
ObjectUtil
.
isEmpty
(
config
.
url
)){
return
true
;
return
true
;
...
@@ -273,4 +348,5 @@ public class SiemensApi {
...
@@ -273,4 +348,5 @@ public class SiemensApi {
return
soap
;
return
soap
;
}
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论