Commit 8d678190 authored by tank.li@mushiny.com's avatar tank.li@mushiny.com

盘点任务回复

parent 93400009
...@@ -44,7 +44,7 @@ public class HeliWMSController { ...@@ -44,7 +44,7 @@ public class HeliWMSController {
public ResponseEntity<MessageDTO> callPod( public ResponseEntity<MessageDTO> callPod(
@RequestBody String json){ @RequestBody String json){
logger.debug("inboundResp: " + json); logger.debug("inboundResp: " + json);
this.wmsToWcsService.sendSingleTripToWcs(8,1,475,0,0); this.wmsToWcsService.sendSingleTripToWcs(8,1,475,3,0);
MessageDTO dto = MessageDTO.success(); MessageDTO dto = MessageDTO.success();
return ResponseEntity.ok(dto); return ResponseEntity.ok(dto);
} }
......
...@@ -109,7 +109,7 @@ public class MqListener { ...@@ -109,7 +109,7 @@ public class MqListener {
newValue.put("POD_ID",podId); newValue.put("POD_ID",podId);
newValue.put("POD_INDEX",CommonUtils.parseInteger("podId",data)); newValue.put("POD_INDEX",CommonUtils.parseInteger("podId",data));
newValue.put("TOWARD",toward); newValue.put("TOWARD",toward);
newValue.put("TRIP_TASK",CommonUtils.parseInteger("taskId",data)); newValue.put("TRIP_TASKID",CommonUtils.parseString("taskId",data));
CommonUtils.modifyUselessInfo(newValue); CommonUtils.modifyUselessInfo(newValue);
Map con = new HashMap(); Map con = new HashMap();
......
package com.mushiny.heli.xnr.wcs;
import org.springframework.web.client.RestClientException;
/**
* Created by Lisi on 2019-12-19.
*/
public class CustomException extends RestClientException {
private RestClientException restClientException;
private String body;
public CustomException(String message, RestClientException scx, String body) {
super(message);
this.restClientException = restClientException;
this.body = body;
}
public CustomException(String msg) {
super(msg);
}
public CustomException(String msg, Throwable ex) {
super(msg, ex);
}
}
package com.mushiny.heli.xnr.wcs;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.web.client.DefaultResponseErrorHandler;
import org.springframework.web.client.ResponseErrorHandler;
import org.springframework.web.client.RestClientException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
public class CustomResponseErrorHandler implements ResponseErrorHandler {
private ResponseErrorHandler errorHandler = new DefaultResponseErrorHandler();
@Override
public void handleError(ClientHttpResponse response) throws IOException {
// 队请求头的处理
List<String> customHeader = response.getHeaders().get("x-app-err-id");
String svcErrorMessageID = "";
if (customHeader != null) {
svcErrorMessageID = customHeader.get(0);
}
//对body 的处理 (inputStream)
String body = convertStreamToString(response.getBody());
try {
errorHandler.handleError(response);
} catch (RestClientException scx) {
throw new CustomException(scx.getMessage(), scx, body);
}
}
@Override
public boolean hasError(ClientHttpResponse response) throws IOException {
return errorHandler.hasError(response);
}
// inputStream 装换为 string
private String convertStreamToString(InputStream is) {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return sb.toString();
}
}
...@@ -5,9 +5,12 @@ import com.mushiny.heli.xnr.comm.JsonUtils; ...@@ -5,9 +5,12 @@ import com.mushiny.heli.xnr.comm.JsonUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.http.*; import org.springframework.http.*;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.client.ResponseErrorHandler;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import java.io.IOException;
import java.util.Map; import java.util.Map;
@Component @Component
...@@ -45,6 +48,7 @@ public class ExecutorHandler { ...@@ -45,6 +48,7 @@ public class ExecutorHandler {
headers.add("Accept", MediaType.APPLICATION_JSON.toString()); headers.add("Accept", MediaType.APPLICATION_JSON.toString());
headers.add("authorization",token); headers.add("authorization",token);
HttpEntity<String> formEntity = new HttpEntity<String>(headers); HttpEntity<String> formEntity = new HttpEntity<String>(headers);
this.restTemplate.setErrorHandler(new CustomResponseErrorHandler());
ResponseEntity<String> result = restTemplate.exchange(url, HttpMethod.GET,formEntity,String.class,params); ResponseEntity<String> result = restTemplate.exchange(url, HttpMethod.GET,formEntity,String.class,params);
...@@ -59,11 +63,13 @@ public class ExecutorHandler { ...@@ -59,11 +63,13 @@ public class ExecutorHandler {
headers.setContentType(type); headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString()); headers.add("Accept", MediaType.APPLICATION_JSON.toString());
headers.add("authorization", token); headers.add("authorization", token);
restTemplate.setErrorHandler(new CustomResponseErrorHandler());
ResponseEntity<String> response = restTemplate.exchange( ResponseEntity<String> response = restTemplate.exchange(
url+"?taskId={taskId}", url+"?taskId={taskId}&sectionId=1",
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<String>(headers), new HttpEntity<String>(headers),
Map.class, params); String.class, params);
logger.error("respose.getBody:"+response.getBody());
return response.getBody(); return response.getBody();
} }
......
...@@ -160,7 +160,8 @@ public class WmsToWcsService{ ...@@ -160,7 +160,8 @@ public class WmsToWcsService{
token = "Bearer " + token; token = "Bearer " + token;
Map<String, Object> taskMap = new HashMap<>(); Map<String, Object> taskMap = new HashMap<>();
taskMap.put("taskId", CommonUtils.parseString("TRIP_TASKID",podStation)); taskMap.put("taskId", CommonUtils.parseString("TRIP_TASKID",podStation));
this.executorHandler.getForObject(this.releasePod, taskMap, token); taskMap.put("sectionId", 1);
this.executorHandler.getMethod(this.releasePod, taskMap, token);
logger.info("工作站 = {} 释放pod = {} ,wcs返回taskId:{}", workStationId, podIndex); logger.info("工作站 = {} 释放pod = {} ,wcs返回taskId:{}", workStationId, podIndex);
//更显pod状态 //更显pod状态
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment