Commit 1a80e36c sunke

PanaCIM系统对接

1 个父辈 9f602532
......@@ -381,6 +381,75 @@ public class PanaApiController extends BaseSmfApiListener {
}
@Override
public Barcode canPutInAfterResolve(String inCheckUrl, CodeValidateParam params, Barcode barcode) throws ValidateException {
String requestReelUrl = getRequestReelUrl();
try {
if(!Strings.isNullOrEmpty(requestReelUrl)){
log.info("向 PanaCIM["+requestReelUrl+"]请求料盘【"+barcode.getBarcode()+"】的信息");
Map<String, Object> reqParams = new HashMap<String, Object>();
reqParams.put("TransactionID", nextSeq("PANA"));
reqParams.put("ErrorCode","0");
reqParams.put("Reelbarcode",barcode.getBarcode());
String result = HttpHelper.postJson(requestReelUrl,reqParams);
log.info("PanaCIM 返回料盘【"+barcode.getBarcode()+"】的信息:"+result);
if(!Strings.isNullOrEmpty(result)){
ObjectMapper mapper = new ObjectMapper();
HashMap<String,Object> jsonMap = mapper.readValue(result, HashMap.class);
String ErrorCode = jsonMap.get("ErrorCode").toString();
if("0".equals(ErrorCode)){//成功
Object qtyObj = jsonMap.get("Quantity");
String qtyStr = "";
if(qtyObj != null){
qtyStr = qtyObj.toString();
}
if(!Strings.isNullOrEmpty(qtyStr)){
/**
* Sample json Data: {
* "TransactionID": "101_MAT_1481090400", "ErrorCode": 0,
* "ReelBarcode": "MAT123567",
* "PartNo": "0805",
* "Quantity": 2000, "Msd": True, "Msdlevel": "4", "Location": "0",
* "MsdDetail”:{
* "FloorLifeExpirationTime":"2017-01-23T21:35:45.5403903Z",
* "ShelfLifeExpirationTime":"2018-06-23T21:35:45.5403903Z",
* “FloorTimeRunning”: true
* }
* } }
*/
int qty = Double.valueOf(qtyStr).intValue();
if(qty > 0){
barcode.setAmount(qty);
}
String partNo = jsonMap.get("PartNo").toString();
if(!partNo.isEmpty()){
barcode.setPartNumber(partNo);
}
}
resolveComponent(barcode);
barcode = barcodeManager.saveBarcode(barcode);
return barcode;
}else{
String errorMsg = "PanaCIM [" + barcode.getBarcode() + "] NG:"+ ErrorCode;
throw new ValidateException(errorMsg, "PanaCIM验证失败");
}
}
}else{
log.info("没有配置PanaCIM条码检测接口,查找setConfiguration注册的IP 及端口");
throw new ValidateException("panacim.noConnect", "No PanaCIM ip and port");
}
}catch (ValidateException ve){
throw ve;
}catch (Exception e) {
String msg = "Request to PanaCIM["+barcode.getBarcode()+"] Error";
log.error(msg,e);
throw new ValidateException("panacim.error", msg + ":"+e.getMessage());
}
return null;
}
@Override
public Barcode canPutInBeforeResolve(String codeResolveUrl, CodeValidateParam codeParams) throws ValidateException {
String requestReelUrl = getRequestReelUrl();
try {
......@@ -453,10 +522,13 @@ public class PanaApiController extends BaseSmfApiListener {
log.info("没有配置PanaCIM条码检测接口,查找setConfiguration注册的IP 及端口");
throw new ValidateException("panacim.noConnect", "No PanaCIM ip and port");
}
} catch (Exception e) {
log.error("Request to PanaCIM["+codeParams.getCode()+"] Error",e);
} catch (ValidateException ve){
throw ve;
}catch (Exception e) {
String msg = "Request to PanaCIM["+codeParams.getCode()+"] Error";
log.error(msg,e);
throw new ValidateException("panacim.error", msg + ":"+e.getMessage());
}
return null;
}
@Override
......@@ -490,7 +562,6 @@ public class PanaApiController extends BaseSmfApiListener {
String inNotifyApi = getInNotifyApi();
try {
if(!Strings.isNullOrEmpty(inNotifyApi)){
log.info("向 PanaCIM["+inNotifyApi+"] 通知料盘【"+task.getBarcode()+"】的入库信息");
//String url = getApiUrl("/api/Storage/checkInNotification");
Map<String, Object> params = new LinkedHashMap<>();
params.put("TransactionID",nextSeq(task.getStorageName()));
......@@ -501,7 +572,7 @@ public class PanaApiController extends BaseSmfApiListener {
params.put("MsdLevel","1");
params.put("Location","0");
params.put("TowerID",task.getStorageName());
log.info("向 PanaCIM["+inNotifyApi+"] 通知料盘【"+task.getBarcode()+"】的入库信息:" + params);
String result = HttpHelper.postJson(inNotifyApi,params);
log.info("Response Of checkInNotification From PanaCIM:"+result);
}else{
......@@ -520,7 +591,6 @@ public class PanaApiController extends BaseSmfApiListener {
String outNotifyApi = getOutNotifyApi();
try {
if(!Strings.isNullOrEmpty(outNotifyApi)){
log.info("向 PanaCIM["+outNotifyApi+"] 通知料盘【"+task.getBarcode()+"】的出库信息");
//String url = getApiUrl("/api/Storage/deliverNotification");
Map<String, Object> params = new HashMap<String, Object>();
params.put("TransactionID",nextSeq(task.getStorageName()));
......@@ -534,7 +604,7 @@ public class PanaApiController extends BaseSmfApiListener {
params.put("Msd",false);
params.put("MsdLevel","1");
params.put("Location","0");
log.info("向 PanaCIM["+outNotifyApi+"] 通知料盘【"+task.getBarcode()+"】的出库信息:" + params);
String result = HttpHelper.postJson(outNotifyApi,params);
log.info("Response Of deliverNotification From PanaCIM:"+result);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!