Commit b3c77f8b sunke

PanaCIM对接

1 个父辈 befc4c4e
......@@ -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>
......
package com.neotel.smfcore.common.exception;
/**
* Created by kangmor on 2015/11/12.
*/
public class ApiException extends Exception {
public ApiException(String message){
super(message);
}
}
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());
}
}
}
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!