Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 9ce8f985
由
LN
编写于
2022-05-11 09:02:25 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
增加西门子接口
1 个父辈
63f88676
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
578 行增加
和
8 行删除
pom.xml
src/main/java/com/neotel/smfcore/common/utils/XmlUtil.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/siemens/SiemensConfig.java
src/main/java/com/neotel/smfcore/siemens/util/WSClientUtil.java
src/main/resources/config/application.yml
src/main/resources/messages.properties
pom.xml
查看文件 @
9ce8f98
...
...
@@ -225,6 +225,16 @@
<artifactId>
httpclient
</artifactId>
<version>
4.4
</version>
</dependency>
<dependency>
<groupId>
com.mks.api
</groupId>
<artifactId>
mksapi-jar
</artifactId>
<version>
4.10.9049
</version>
</dependency>
<dependency>
<groupId>
commons-httpclient
</groupId>
<artifactId>
commons-httpclient
</artifactId>
<version>
3.1
</version>
</dependency>
</dependencies>
...
...
src/main/java/com/neotel/smfcore/common/utils/XmlUtil.java
0 → 100644
查看文件 @
9ce8f98
package
com
.
neotel
.
smfcore
.
common
.
utils
;
import
java.util.ArrayList
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
* 此类提供XML或Json字符串内容的解析,及由XML字符串到JSON对象的转换
*
* @author SunKe
*
*/
public
class
XmlUtil
{
/**
*
* 在给定的元素中搜索指定的元素,返回符合条件的元素数组.对于不同级别的同名元素限制作用,即可以
* 搜索元素A中的子元素C.而对于元素B中子元素C则过虑,通过多级限定可以准确定位.
*
* @param nodeName
* 节点名称
* @param xmlData
* XML内容
* @return
*/
public
static
List
<
String
>
getElementsByNode
(
String
nodeName
,
String
xmlData
)
{
List
<
String
>
tagElements
=
new
ArrayList
<
String
>();
//xmlData = removeNewLineChar(xmlData);
String
regex
=
"(?s)<"
+
nodeName
+
"\\s?[^>]*?((>(.*?)</"
+
nodeName
+
">)|(/>))"
;
Pattern
p
=
Pattern
.
compile
(
regex
.
toString
());
Matcher
m
=
p
.
matcher
(
xmlData
);
while
(
m
.
find
())
{
tagElements
.
add
(
m
.
group
());
}
return
tagElements
;
}
/**
* 获取不带外部标签的body
* @param nodeName
* @param xmlData
* @return
*/
public
static
List
<
String
>
getNodeBodys
(
String
nodeName
,
String
xmlData
)
{
List
<
String
>
tagElements
=
new
ArrayList
<
String
>();
//xmlData = removeNewLineChar(xmlData);
String
regex
=
"(?s)<"
+
nodeName
+
"\\s?[^>]*?((>(.*?)</"
+
nodeName
+
">)|(/>))"
;
Pattern
p
=
Pattern
.
compile
(
regex
.
toString
());
Matcher
m
=
p
.
matcher
(
xmlData
);
while
(
m
.
find
())
{
tagElements
.
add
(
m
.
group
(
3
));
}
return
tagElements
;
}
public
static
String
getNodeBody
(
String
nodeName
,
String
xmlData
){
List
<
String
>
list
=
getNodeBodys
(
nodeName
,
xmlData
);
if
(
list
.
isEmpty
()){
return
""
;
}
return
list
.
get
(
0
);
}
public
static
String
getElementByNode
(
String
nodeName
,
String
xmlData
){
List
<
String
>
list
=
getElementsByNode
(
nodeName
,
xmlData
);
if
(
list
.
isEmpty
()){
return
""
;
}
return
list
.
get
(
0
);
}
/**
* 获取XML某一节点所有的属性值,返回一个包含属性和值的Map,Map的键为属性名称,值为属性值.
*
* @param nodeName
* 节点名称
* @param xmlData
* XML内容
* @return 包含此节点所有属性和值的Map
*/
public
static
Map
<
String
,
String
>
getNodeAttributes
(
String
nodeName
,
String
xmlData
)
{
return
getNodeAttributes
(
nodeName
,
""
,
xmlData
);
}
public
static
String
getNodeAttribute
(
String
nodeName
,
String
attributeName
,
String
xmlData
){
//xmlData = removeNewLineChar(xmlData);
StringBuilder
regex
=
new
StringBuilder
(
"(?s)<"
);
regex
.
append
(
nodeName
);
regex
.
append
(
"\\s([^>]*?"
);
regex
.
append
(
""
+
attributeName
+
"=\"([^\"]*)\""
);
regex
.
append
(
"[^>]*?)[>|/>]"
);
Pattern
p
=
Pattern
.
compile
(
regex
.
toString
());
Matcher
m
=
p
.
matcher
(
xmlData
);
if
(
m
.
find
())
{
String
full
=
m
.
group
(
2
).
trim
();
return
full
;
}
return
""
;
}
/**
* 获取XML某一节点所有的属性值,返回一个包含属性和值的Map,Map的键为属性名称,值为属性值.
* 正则表达式为"<nodeName\s([^>]+?includeStr[^>]+?)[>|/>]>"
*
* @param nodeName
* 节点名称
* @param includeStr
* 节点属性中要包含的字符串
* @param xmlData
* XML内容
* @return 包含此节点所有属性和值的Map
*/
public
static
Map
<
String
,
String
>
getNodeAttributes
(
String
nodeName
,
String
includeStr
,
String
xmlData
)
{
//xmlData = removeNewLineChar(xmlData);
Map
<
String
,
String
>
result
=
new
LinkedHashMap
<
String
,
String
>();
StringBuilder
regex
=
new
StringBuilder
(
"(?s)<"
);
regex
.
append
(
nodeName
);
regex
.
append
(
"\\s([^>]+?"
);
regex
.
append
(
includeStr
);
regex
.
append
(
"[^>]+?)[>|/>]"
);
Pattern
p
=
Pattern
.
compile
(
regex
.
toString
());
Matcher
m
=
p
.
matcher
(
xmlData
);
if
(
m
.
find
())
{
String
full
=
m
.
group
(
1
).
trim
();
String
[]
itemGroup
=
full
.
split
(
" "
);
for
(
String
item
:
itemGroup
)
{
item
=
item
.
replaceAll
(
"\""
,
""
);
// 去除所有引号
String
[]
itemData
=
item
.
split
(
"="
);
if
(
itemData
.
length
==
2
)
{
result
.
put
(
itemData
[
0
].
trim
(),
itemData
[
1
].
trim
());
}
}
}
return
result
;
}
/**
* 将所有的换行符替换为空格,如\r,\n等
*/
public
static
String
removeNewLineChar
(
String
str
)
{
return
str
.
replaceAll
(
"[\\r\\n|\\n|\\r]"
,
" "
).
trim
();
}
/**
* 替换标签中的属性
*/
public
static
String
replaceAttribute
(
String
xmlData
,
String
attributeName
,
String
attributeValue
){
String
regex
=
"\\s"
+
attributeName
+
"=\"[^\"]*\""
;
return
xmlData
.
replaceAll
(
regex
,
" "
+
attributeName
+
"=\""
+
attributeValue
+
"\""
);
}
/**
* 替换XML中的标签
*/
public
static
String
replaceNode
(
String
xmlData
,
String
nodeName
,
String
newStr
){
String
regex
=
"(?s)<"
+
nodeName
+
"\\s?[^>]*?((>.*?</"
+
nodeName
+
">)|(/>))"
;
return
xmlData
.
replaceAll
(
regex
,
newStr
);
}
public
static
void
main
(
String
args
[]){
//new Client().start();
// String xml ="<message>\n" +
// "<header messageClass=\"511\" transactionID=\"1234567891\" reply=\"1\">\n" +
// "<location routeID=\"1001\" routeName=\"LA\" equipmentID=\"1001\" equipmentName=\"LA- NPM1\"\n" +
// "zonePos=“1” zoneName=\"LA-NPM1\" laneNo=\"0\"/> </header>\n" +
// "<body>\n" +
// "<material id=\" SpliceReel \" qty=\"400\" /> <offline value = \"1\" />\n" +
// "<machineSide value =\"R\" />\n" +
// "</body> </message>";
// List<String> headers = getElementsByNode("header",xml);
// System.out.println("="+headers.get(0)+"=");
// String result = getNodeAttribute("header", "transactionID", xml);
// System.out.println("="+result+"=");
String
xml
=
"<XmlCommand><Command>GetTowerInformation</Command><Parameter>006273</Parameter></XmlCommand>"
;
System
.
out
.
println
(
"="
+
getNodeBody
(
"parameter"
,
xml
.
toLowerCase
()));
}
}
src/main/java/com/neotel/smfcore/core/device/handler/impl/BaseDeviceHandler.java
查看文件 @
9ce8f98
...
...
@@ -43,9 +43,11 @@ import com.neotel.smfcore.core.system.service.po.Humiture;
import
com.neotel.smfcore.core.system.util.DevicesStatusUtil
;
import
com.neotel.smfcore.core.system.util.TaskService
;
import
com.neotel.smfcore.security.service.manager.IGroupManager
;
import
com.neotel.smfcore.siemens.SiemensApi
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.web.csrf.CsrfTokenRepository
;
import
org.springframework.stereotype.Service
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -249,6 +251,12 @@ public class BaseDeviceHandler implements IDeviceHandler {
barcodeSave
=
codeResolve
.
resolveOneValideBarcode
(
codeStr
,
type
);
}
//西门子接口验证
boolean
result
=
SiemensApi
.
getMaterialLot
(
1
,
storage
.
getId
(),
storage
.
getName
(),
barcodeSave
.
getBarcode
());
if
(!
result
)
{
throw
new
ValidateException
(
"smfcore.error.getMaterialLot.in"
,
"条码[{0}]验证失败,无法入库"
,
new
String
[]{
barcodeSave
.
getBarcode
()});
}
//查找库位,生成入库任务
DataLog
putInTask
=
generatePutInTask
(
statusBean
,
barcodeSave
,
storage
);
...
...
@@ -649,6 +657,10 @@ public class BaseDeviceHandler implements IDeviceHandler {
//更新缓存中的库存信息
task
.
setStatus
(
OP_STATUS
.
FINISHED
.
name
());
taskService
.
updateFinishedTask
(
task
);
//调用西门子接口
SiemensApi
.
processMaterialLot
(
1
,
storagePos
.
getStorageId
(),
task
.
getStorageName
(),
barcode
.
getBarcode
());
}
/**
...
...
@@ -696,6 +708,9 @@ public class BaseDeviceHandler implements IDeviceHandler {
//更新缓存中的库存信息
dataCache
.
updateInventory
(
storagePos
,
barcode
);
//调用西门子接口
SiemensApi
.
processMaterialLot
(
2
,
storagePos
.
getStorageId
(),
task
.
getStorageName
(),
barcode
.
getBarcode
());
//记录日志
task
.
setStatus
(
OP_STATUS
.
FINISHED
.
name
());
taskService
.
updateFinishedTask
(
task
);
...
...
src/main/java/com/neotel/smfcore/core/device/handler/impl/MimoBoxHandler.java
查看文件 @
9ce8f98
...
...
@@ -14,6 +14,7 @@ import com.neotel.smfcore.core.storage.enums.DeviceType;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.storage.service.po.StoragePos
;
import
com.neotel.smfcore.core.system.util.DevicesStatusUtil
;
import
com.neotel.smfcore.siemens.SiemensApi
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -121,6 +122,13 @@ public class MimoBoxHandler extends BaseDeviceHandler {
if
(
pos
==
null
)
{
throw
new
ValidateException
(
"smfcore.error.mimo.outFial"
,
"未找到可出库的物料"
,
new
String
[]{
storageId
});
}
else
{
//西门子接口验证
boolean
result
=
SiemensApi
.
getMaterialLot
(
2
,
storage
.
getId
(),
storage
.
getName
(),
pos
.
getBarcode
().
getBarcode
());
if
(!
result
)
{
throw
new
ValidateException
(
"smfcore.error.getMaterialLot.out"
,
"条码[{0}]验证失败,无法出库"
,
new
String
[]{
pos
.
getBarcode
().
getBarcode
()});
}
log
.
info
(
"根据PN单盘出库:【"
+
storage
.
getName
()
+
"_"
+
storage
.
getCid
()
+
"】位置仓位【"
+
pos
.
getPosName
()
+
"】"
);
String
outResult
=
taskService
.
checkout
(
storage
,
pos
,
true
,
SecurityUtils
.
getCurrentUsername
());
if
(!
Strings
.
isNullOrEmpty
(
outResult
))
{
...
...
src/main/java/com/neotel/smfcore/core/storage/rest/StoragePosController.java
查看文件 @
9ce8f98
...
...
@@ -25,22 +25,15 @@ import com.neotel.smfcore.core.storage.rest.dto.StoragePosSaveDto;
import
com.neotel.smfcore.core.storage.rest.mapstruct.StoragePosMapper
;
import
com.neotel.smfcore.core.storage.rest.query.StoragePosFindCriteria
;
import
com.neotel.smfcore.core.storage.rest.query.StoragePosQueryCriteria
;
import
com.neotel.smfcore.core.storage.service.dao.IStoragePosDao
;
import
com.neotel.smfcore.core.storage.service.manager.IStoragePosManager
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.storage.service.po.StoragePos
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.core.system.util.TaskService
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
com.neotel.smfcore.security.rest.bean.query.UserQueryCriteria
;
import
com.neotel.smfcore.security.service.po.User
;
import
com.neotel.smfcore.siemens.SiemensApi
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.Data
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
net.bytebuddy.asm.Advice
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.mongodb.core.query.Criteria
;
...
...
@@ -86,6 +79,7 @@ public class StoragePosController {
@GetMapping
@PreAuthorize
(
"@el.check('storagePos:list')"
)
public
PageData
<
StoragePosDto
>
query
(
StoragePosQueryCriteria
criteria
,
Pageable
pageable
)
{
// SiemensApi.getMaterialLot(1,"1","aaa","maid");
if
(
criteria
.
getStorageIdList
()
!=
null
&&
criteria
.
getStorageIdList
().
contains
(
"0"
))
{
criteria
.
setStorageIdList
(
null
);
}
...
...
@@ -345,6 +339,12 @@ public class StoragePosController {
// throw new ValidateException("料仓[" + pos.getStorageId() + "]不存在");
}
//西门子接口验证
boolean
result
=
SiemensApi
.
getMaterialLot
(
2
,
storage
.
getId
(),
storage
.
getName
(),
pos
.
getBarcode
().
getBarcode
());
if
(!
result
)
{
throw
new
ValidateException
(
"smfcore.error.getMaterialLot.out"
,
"条码[{0}]验证失败,无法出库"
,
new
String
[]{
pos
.
getBarcode
().
getBarcode
()});
}
log
.
info
(
"出库料仓【"
+
storage
.
getName
()
+
"_"
+
storage
.
getCid
()
+
"】位置仓位【"
+
pos
.
getPosName
()
+
"】"
);
String
outResult
=
taskService
.
checkout
(
storage
,
pos
,
isSingleOut
,
SecurityUtils
.
getCurrentUsername
());
if
(!
Strings
.
isNullOrEmpty
(
outResult
))
{
...
...
src/main/java/com/neotel/smfcore/siemens/SiemensApi.java
0 → 100644
查看文件 @
9ce8f98
package
com
.
neotel
.
smfcore
.
siemens
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.utils.XmlUtil
;
import
com.neotel.smfcore.siemens.util.WSClientUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
@Slf4j
@Component
public
class
SiemensApi
{
private
static
SiemensConfig
config
;
@Autowired
public
void
setConfig
(
SiemensConfig
config
){
SiemensApi
.
config
=
config
;
}
public
static
boolean
getMaterialLot
(
int
inoutType
,
String
storageId
,
String
storageName
,
String
materialLot
){
if
(
ObjectUtil
.
isEmpty
(
config
.
url
)){
return
true
;
}
String
action
=
config
.
action_GetMaterialLot
;
String
msg
=
"getMaterialLot ["
+
inoutType
+
"]["
+
storageId
+
"]["
+
storageName
+
"]["
+
materialLot
+
"] :"
;
String
soap
=
buildXml
(
action
,
inoutType
,
storageId
,
storageName
,
materialLot
);
// //XML测试
// String text= XmlUtil.getElementByNode("a:Action", soap );
// String text2= XmlUtil.getNodeBody("a:Action", soap );
// String text3= XmlUtil.getNodeAttribute("DataArea","xmlns", soap );
String
returnData
=
WSClientUtil
.
sendSoap
(
config
.
host
,
config
.
GetPort
(),
config
.
url
,
soap
);
if
(
ObjectUtil
.
isEmpty
(
returnData
)){
log
.
error
(
msg
+
"未收到结果"
);
return
true
;
}
else
{
//2 facts server反馈的actionCode为Accepted时,执行步骤3, actionCode为Rejected时不允许出库
String
actionCode
=
XmlUtil
.
getNodeAttribute
(
"ResponseExpression"
,
"actionCode"
,
returnData
);
String
msgBody
=
XmlUtil
.
getNodeBody
(
"ResponseExpression"
,
returnData
);
if
(
ObjectUtil
.
isNotEmpty
(
actionCode
))
{
if
(
actionCode
.
equals
(
"Accepted"
))
{
log
.
info
(
msg
+
" 返回,actionCode = "
+
actionCode
+
","
+
msgBody
);
return
true
;
}
}
log
.
info
(
msg
+
" 返回,actionCode = "
+
actionCode
+
","
+
msgBody
);
return
false
;
}
// 参数如下:
// Action: http://siplace.com/facts/materiallot/2010/01/MaterialLot/GetMaterialLot
// MaterialLot的ID为料盘的唯一码
// String soap="<a:Action s:mustUnderstand=\"1\">"+action+"</a:Action>"
// + "<DataArea xmlns=\"http://www.wbf.org/xml/b2mml-v0400\">"
// + "<Get>"
// + "<Expression>Get</Expression>"
// + "</Get>"
// + "<MaterialLot>"
// + "<ID>"
// + "<Value>"+MaterialLot+"</Value>"
// + "</ID>"
// + "</MaterialLot>"
// + "</DataArea>";
}
public
static
boolean
processMaterialLot
(
int
inoutType
,
String
storageId
,
String
storageName
,
String
materialLot
){
if
(
ObjectUtil
.
isEmpty
(
config
.
url
)){
return
true
;
}
String
action
=
config
.
action_ProcessMaterialLot
;
String
msg
=
"processMaterialLot ["
+
inoutType
+
"]["
+
storageId
+
"]["
+
storageName
+
"]["
+
materialLot
+
"] :"
;
String
soap
=
buildXml
(
action
,
inoutType
,
storageId
,
storageName
,
materialLot
);
String
returnData
=
WSClientUtil
.
sendSoap
(
config
.
host
,
config
.
GetPort
(),
config
.
url
,
soap
);
if
(
ObjectUtil
.
isEmpty
(
returnData
)){
log
.
error
(
msg
+
"未收到结果"
);
return
true
;
}
else
{
//facts server收到信息后,反回OK,出库流程结束
String
actionCode
=
XmlUtil
.
getNodeAttribute
(
"ResponseExpression"
,
"actionCode"
,
returnData
);
String
msgBody
=
XmlUtil
.
getNodeBody
(
"ResponseExpression"
,
returnData
);
if
(
ObjectUtil
.
isNotEmpty
(
actionCode
))
{
if
(
actionCode
.
equals
(
"Accepted"
))
{
log
.
info
(
msg
+
" 返回,actionCode = "
+
actionCode
+
","
+
msgBody
);
return
true
;
}
}
log
.
info
(
msg
+
" 返回,actionCode = "
+
actionCode
+
","
+
msgBody
);
return
false
;
}
// String soap="<a:Action s:mustUnderstand=\"1\">"+action+"</a:Action>"
// + "<DataArea xmlns=\"http://www.wbf.org/xml/b2mml-v0400\">"
// +"<Process>"
// +"<ActionCriteria>"
// +"<ActionExpression actionCode=\""+action+"\"/>"
// +"</ActionCriteria>"
// +"</Process>"
// + "<MaterialLot>"
// + "<ID>"
// + "<Value>"+materialLot+"</Value>"
// + "</ID>"
// + "<Location>"
// + "<EquipmentID>"
// + "<Value>"+storageName+"</Value>"
// + "</EquipmentID>"
// + "</Location>"
// + "</MaterialLot>"
// + "</DataArea>";
// Action: http://siplace.com/facts/materiallot/2010/01/MaterialLot/ProcessMaterialLot
// actionCode: 入库为Charge, 出库为DisCharge
// MaterialLot 的ID为料盘的唯一码
// EquipmentID为Tower设备的编号(每台Tower不一样) //料仓名称
}
private
static
String
buildXml
(
String
actionCode
,
int
inoutType
,
String
storageId
,
String
storageName
,
String
materialLot
){
//1=入库,2=出库
String
inoutTypeStr
=
"Charge"
;
if
(
inoutType
==
2
){
inoutTypeStr
=
"DisCharge"
;
}
String
soap
=
"<?xml version=\"1.0\"?>"
+
"<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\">"
+
"<s:Header>"
+
"<a:Action s:mustUnderstand=\"1\">"
+
actionCode
+
"</a:Action>"
+
"<a:MessageID>urn:uuid:9a3a1214-eb2a-4e87-a5b8-94f71e540f59</a:MessageID><a:ReplyTo>"
+
"<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>"
+
"</a:ReplyTo>"
+
"<CallerId xmlns=\"http://siplace.com/facts\">8100449b-4b84-450b-aaab-48a419b13787</CallerId>"
+
"<CallerName xmlns=\"http://siplace.com/facts\">Rojonic</CallerName>"
+
"<Signature xmlns=\"http://siplace.com/facts\">62C28B8F3033423c9286658A67D67674</Signature>"
+
"<a:To s:mustUnderstand=\"1\">http://cnctu04053.cn104.local/FactsWebServices/MaterialLot.svc</a:To>"
+
"</s:Header>"
+
"<s:Body xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
+
"<ProcessMaterialLotType xmlns=\"http://siplace.com/facts/materiallot/2010/01\" versionID=\"2.0.0.1642\" releaseID=\"2.0.0.1642\">"
+
"<ApplicationArea xmlns=\"http://www.wbf.org/xml/b2mml-v0400\">"
+
"<Sender>"
+
"<LogicalID>"
+
"<Value>"
+
storageName
+
"</Value>"
+
"</LogicalID>"
+
"<ComponentID>"
+
"<Value>"
+
storageId
+
"</Value>"
+
"</ComponentID>"
+
"<ConfirmationCode languageID=\"de-DE\">Always</ConfirmationCode>"
+
"</Sender>"
+
"<CreationDateTime>2022-01-27T17:13:30.2032951+08:00</CreationDateTime>"
+
"</ApplicationArea>"
+
"<DataArea xmlns=\"http://www.wbf.org/xml/b2mml-v0400\">"
+
"<Process>"
+
"<ActionCriteria>"
+
"<ActionExpression actionCode=\""
+
inoutTypeStr
+
"\"/>"
+
"</ActionCriteria>"
+
"</Process>"
+
"<MaterialLot>"
+
"<ID>"
+
"<Value>"
+
materialLot
+
"</Value>"
+
"</ID>"
+
"<Location>"
+
"<EquipmentID>"
+
"<Value>"
+
storageName
+
"</Value>"
+
"</EquipmentID>"
+
"</Location>"
+
"</MaterialLot>"
+
"</DataArea>"
+
"</ProcessMaterialLotType>"
+
"</s:Body>"
+
"</s:Envelope>"
;
return
soap
;
}
}
src/main/java/com/neotel/smfcore/siemens/SiemensConfig.java
0 → 100644
查看文件 @
9ce8f98
package
com
.
neotel
.
smfcore
.
siemens
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.PostConstruct
;
@Service
@Slf4j
public
class
SiemensConfig
{
//读取配置中的地址
@Value
(
"${siemens.host:}"
)
public
String
host
=
""
;
@Value
(
"${siemens.port:}"
)
public
String
port
=
""
;
@Value
(
"${siemens.url:}"
)
public
String
url
=
""
;
@Value
(
"${siemens.action.GetMaterialLot:}"
)
public
String
action_GetMaterialLot
=
""
;
@Value
(
"${siemens.action.ProcessMaterialLot:}"
)
public
String
action_ProcessMaterialLot
=
""
;
public
int
GetPort
(){
try
{
return
Integer
.
parseInt
(
host
);
}
catch
(
Exception
ex
){
}
return
0
;
}
@Autowired
private
DataCache
dataCache
;
@PostConstruct
public
void
init
()
{
host
=
dataCache
.
GetConfigCache
(
"siemens.host"
,
"siemens.host"
,
url
);
port
=
dataCache
.
GetConfigCache
(
"siemens.port"
,
"siemens.port"
,
url
);
url
=
dataCache
.
GetConfigCache
(
"siemens.url"
,
"siemens.url"
,
url
);
action_GetMaterialLot
=
dataCache
.
GetConfigCache
(
"siemens.action.GetMaterialLot"
,
"siemens.action.GetMaterialLot"
,
action_GetMaterialLot
);
action_ProcessMaterialLot
=
dataCache
.
GetConfigCache
(
"siemens.action.ProcessMaterialLot"
,
"siemens.action.ProcessMaterialLot"
,
action_ProcessMaterialLot
);
log
.
info
(
"siemens服务器rul:"
+
url
+
",GetMaterialLot="
+
action_GetMaterialLot
+
",ProcessMaterialLot="
+
action_ProcessMaterialLot
);
}
}
src/main/java/com/neotel/smfcore/siemens/util/WSClientUtil.java
0 → 100644
查看文件 @
9ce8f98
package
com
.
neotel
.
smfcore
.
siemens
.
util
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.httpclient.HostConfiguration
;
import
org.apache.commons.httpclient.HttpClient
;
import
org.apache.commons.httpclient.HttpException
;
import
org.apache.commons.httpclient.methods.PostMethod
;
import
org.springframework.util.CollectionUtils
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.util.HashMap
;
import
java.util.Map
;
@Slf4j
public
class
WSClientUtil
{
public
static
String
sendSoap
(
String
host
,
Integer
port
,
String
url
,
String
soap
)
{
HttpClient
httpClient
=
new
HttpClient
();
HostConfiguration
hostConfiguration
=
new
HostConfiguration
();
hostConfiguration
.
setHost
(
host
,
port
);
httpClient
.
setHostConfiguration
(
hostConfiguration
);
httpClient
.
setTimeout
(
1000
);
httpClient
.
setConnectionTimeout
(
1000
);
PostMethod
postMethod
=
new
PostMethod
();
// postMethod.setPath(url ); //路径和wsdl名
postMethod
.
setPath
(
url
+
"/ncg.wsdl"
);
//路径和wsdl名
// String soap = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
// + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soapenv:Body><ns1:GetNcgOnlineInfo soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:ns1=\"urn:ncg\"/></soapenv:Body></soapenv:Envelope>";
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
"Content-Type"
,
"application/soap+xml; charset=utf-8"
);
try
{
byte
[]
b
=
soap
.
getBytes
(
"utf-8"
);
// InputStream is = new ByteArrayInputStream(b, 0, b.length);
// RequestEntity re = new InputStreamRequestEntity(is, b.length,
// "application/soap+xml; charset=utf-8");
// postMethod.setRequestEntity(re);
if
(!
CollectionUtils
.
isEmpty
(
headers
))
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
headers
.
entrySet
())
{
postMethod
.
addRequestHeader
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
int
statusCode
=
httpClient
.
executeMethod
(
postMethod
);
String
soapResponseData
=
postMethod
.
getResponseBodyAsString
();
log
.
info
(
"sendSoap 返回:["
+
statusCode
+
"],["
+
soapResponseData
+
"]"
);
postMethod
.
releaseConnection
();
//解析
System
.
out
.
println
(
soapResponseData
.
split
(
"<response xsi:type=\"xsd:string\">"
)[
1
].
split
(
"</response>"
)[
0
]);
return
soapResponseData
;
}
catch
(
UnsupportedEncodingException
e1
)
{
// TODO Auto-generated catch block
e1
.
printStackTrace
();
log
.
error
(
"sendSoap error :"
,
e1
);
}
catch
(
HttpException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
log
.
error
(
"sendSoap error :"
,
e
);
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
log
.
error
(
"sendSoap error :"
,
e
);
}
return
""
;
}
// public void demo(String url){
//
// HttpClient httpClient=new HttpClient();
// PostMethod postMethod=new PostMethod();
// postMethod.setPath(url+"/ncg.wsdl"); //路径和wsdl名
//
// String soap = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
// + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soapenv:Body><ns1:GetNcgOnlineInfo soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:ns1=\"urn:ncg\"/></soapenv:Body></soapenv:Envelope>";
//
// try {
// byte[] b=soap.getBytes("utf-8");
//
// InputStream is = new ByteArrayInputStream(b, 0, b.length);
// RequestEntity re = new InputStreamRequestEntity(is, b.length,
// "application/soap+xml; charset=utf-8");
// postMethod.setRequestEntity(re);
// int statusCode = httpClient.executeMethod(postMethod);
//
// String soapResponseData = postMethod.getResponseBodyAsString();
//
// postMethod.releaseConnection();
// //解析
// System.out.println(soapResponseData.split("<response xsi:type=\"xsd:string\">")[1].split("</response>")[0]);
// } catch (UnsupportedEncodingException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// } catch (HttpException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
//
// }
}
src/main/resources/config/application.yml
查看文件 @
9ce8f98
...
...
@@ -5,6 +5,14 @@ hella:
#host: 127.0.0.1
port
:
3333
siemens
:
host
:
"
127.0.0.1"
port
:
3333
# url: "http://cnctu04053.cn104.local/FactsWebServices/MaterialLot.svc"
action
:
GetMaterialLot
:
"
http://siplace.com/facts/materiallot/2010/01/MaterialLot/GetMaterialLot"
ProcessMaterialLot
:
"
http://siplace.com/facts/materiallot/2010/01/MaterialLot/ProcessMaterialLot"
# 文件存储路径
file
:
mac
:
~/file/
...
...
src/main/resources/messages.properties
查看文件 @
9ce8f98
...
...
@@ -256,6 +256,8 @@ smfcore.greaterThanZero=\u6570\u91CF\u5FC5\u987B\u5927\u4E8E0
smfcore.error.virtualOut.num
=
\u6570\u
91CF
\u
4E0D
\u
80FD
\u
8D85
\u
8FC7{0}
smfcore.error.virtualOut.noItem
=
\u
5DE5
\u5355
{0}
\u
4E2D
\u
672A
\u
627E
\u5230\u
5BF9
\u
5E94
\u7684
PN
\u6216\u7269\u6599\u
7F16
\u
53F7
smfcore.error.mimo.outFial
=
\u
672A
\u
627E
\u5230\u
53EF
\u
51FA
\u
5E93
\u7684\u7269\u6599
smfcore.error.getMaterialLot.in
=
\u6761\u7801
[{0}]
\u
9A8C
\u
8BC1
\u5931\u
8D25
\u
FF0C
\u
65E0
\u
6CD5
\u5165\u
5E93
smfcore.error.getMaterialLot.out
=
\u6761\u7801
[{0}]
\u
9A8C
\u
8BC1
\u5931\u
8D25
\u
FF0C
\u
65E0
\u
6CD5
\u
51FA
\u
5E93
#smfclient.nlp.onlyOneTray=\u4E0D\u53EF\u540C\u65F6\u653E\u5165\u591A\u76D8\u7269\u6599:{0}
#smfclient.nlp.cannotFindPos={0}\u672A\u627E\u5230\u5E93\u4F4D:{1}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论