Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit b3c77f8b
由
sunke
编写于
2022-02-07 10:32:55 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
PanaCIM对接
1 个父辈
befc4c4e
全部展开
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
185 行增加
和
3 行删除
pom.xml
src/main/java/com/neotel/smfcore/common/exception/ApiException.java
src/main/java/com/neotel/smfcore/common/utils/HttpHelper.java
src/main/java/com/neotel/smfcore/panacim/PanaApiController.java
src/main/java/com/neotel/smfcore/panacim/PanaMaterial.java
pom.xml
查看文件 @
b3c77f8
...
...
@@ -186,17 +186,17 @@
<dependency>
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct
</artifactId>
<version>
1.
3.1
.Final
</version>
<version>
1.
4.2
.Final
</version>
</dependency>
<dependency>
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct-processor
</artifactId>
<version>
1.
3.1
.Final
</version>
<version>
1.
4.2
.Final
</version>
</dependency>
<dependency>
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct-jdk8
</artifactId>
<version>
1.4.
0
.Final
</version>
<version>
1.4.
2
.Final
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.mina/mina-core -->
...
...
@@ -220,6 +220,11 @@
<artifactId>
core
</artifactId>
<version>
3.2.1
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
4.4
</version>
</dependency>
</dependencies>
...
...
src/main/java/com/neotel/smfcore/common/exception/ApiException.java
0 → 100644
查看文件 @
b3c77f8
package
com
.
neotel
.
smfcore
.
common
.
exception
;
/**
* Created by kangmor on 2015/11/12.
*/
public
class
ApiException
extends
Exception
{
public
ApiException
(
String
message
){
super
(
message
);
}
}
src/main/java/com/neotel/smfcore/common/utils/HttpHelper.java
0 → 100755
查看文件 @
b3c77f8
package
com
.
neotel
.
smfcore
.
common
.
utils
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.neotel.smfcore.common.exception.ApiException
;
import
lombok.val
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.util.EntityUtils
;
import
org.apache.logging.log4j.util.Strings
;
import
java.io.*
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.util.*
;
import
java.util.Map.Entry
;
/**
* HTTP网络请求
*/
public
class
HttpHelper
{
// 编码方式
private
static
final
String
CONTENT_CHARSET
=
"UTF-8"
;
public
static
String
postJson
(
String
url
,
Map
<
String
,
Object
>
params
)
throws
ApiException
{
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
HttpPost
httpPost
=
new
HttpPost
(
url
);
httpPost
.
addHeader
(
"Content-Type"
,
"application/json;charset=utf-8"
);
// 设置请求参数
if
(
params
!=
null
&&
!
params
.
isEmpty
())
{
ObjectMapper
mapper
=
new
ObjectMapper
();
try
{
String
requestBody
=
mapper
.
writeValueAsString
(
params
);
httpPost
.
setEntity
(
new
StringEntity
(
requestBody
));
}
catch
(
JsonProcessingException
e
)
{
throw
new
ApiException
(
"Request params to ["
+
url
+
"] failed:"
+
e
.
getMessage
());
}
catch
(
UnsupportedEncodingException
e
)
{
throw
new
ApiException
(
"Request params to ["
+
url
+
"] failed:"
+
e
.
getMessage
());
}
}
try
{
CloseableHttpResponse
response
=
httpClient
.
execute
(
httpPost
);
//System.out.println(response.getStatusLine().getStatusCode() + "\n");
HttpEntity
entity
=
response
.
getEntity
();
String
responseContent
=
EntityUtils
.
toString
(
entity
,
CONTENT_CHARSET
);
response
.
close
();
httpClient
.
close
();
return
responseContent
;
}
catch
(
Exception
e
){
throw
new
ApiException
(
"Request to ["
+
url
+
"] failed:"
+
e
.
getMessage
());
}
}
}
src/main/java/com/neotel/smfcore/panacim/PanaApiController.java
查看文件 @
b3c77f8
此文件的差异被折叠,
点击展开。
src/main/java/com/neotel/smfcore/panacim/PanaMaterial.java
0 → 100644
查看文件 @
b3c77f8
package
com
.
neotel
.
smfcore
.
panacim
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
java.util.List
;
/**
* Created by sunke on 17/4/17.
*/
public
class
PanaMaterial
{
@JsonProperty
(
"TransactionID"
)
String
transactionID
;
@JsonProperty
(
"TowerID"
)
String
towerID
;
@JsonProperty
(
"Priority"
)
String
priority
;
@JsonProperty
(
"Display"
)
String
display
;
// String Timestamp = request.getParameter("Timestamp");//Date(2009-02-15T00:00:00Z)
@JsonProperty
(
"JobID"
)
String
jobID
;
@JsonProperty
(
"ReelBarcodes"
)
List
<
String
>
ReelBarcodes
;
@JsonProperty
(
"TransactionType"
)
String
transactionType
;
@JsonProperty
(
"ReelBarcodesReserved"
)
List
<
String
>
reelBarcodesReserved
;
public
String
getTransactionID
()
{
return
transactionID
;
}
public
void
setTransactionID
(
String
transactionID
)
{
this
.
transactionID
=
transactionID
;
}
public
String
getTowerID
()
{
return
towerID
;
}
public
void
setTowerID
(
String
towerID
)
{
this
.
towerID
=
towerID
;
}
public
String
getJobID
()
{
return
jobID
;
}
public
void
setJobID
(
String
jobID
)
{
this
.
jobID
=
jobID
;
}
public
List
<
String
>
getReelBarcodes
()
{
return
ReelBarcodes
;
}
public
void
setReelBarcodes
(
List
<
String
>
reelBarcodes
)
{
ReelBarcodes
=
reelBarcodes
;
}
public
String
getTransactionType
()
{
return
transactionType
;
}
public
void
setTransactionType
(
String
transactionType
)
{
this
.
transactionType
=
transactionType
;
}
public
List
<
String
>
getReelBarcodesReserved
()
{
return
reelBarcodesReserved
;
}
public
void
setReelBarcodesReserved
(
List
<
String
>
reelBarcodesReserved
)
{
this
.
reelBarcodesReserved
=
reelBarcodesReserved
;
}
public
String
getDisplay
()
{
return
display
;
}
public
void
setDisplay
(
String
display
)
{
this
.
display
=
display
;
}
public
String
getPriority
()
{
return
priority
;
}
public
void
setPriority
(
String
priority
)
{
this
.
priority
=
priority
;
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论