Commit 571aded1 LN

API010 增加重试逻辑. API002超时改为2分钟。api009返回key改为大小写兼容。

1 个父辈 aa69b9a4
......@@ -215,4 +215,13 @@ public class Constants {
* 镁光url地址:http://istio-ingressgateway-istio-system.apps.ose-dev45.micron.com/
*/
public static final String CACHE_Micron_AppAddr ="CACHE_Micron_AppAddr";
/**
*API010运行自动retry次数
*/
public static final String CACHE_API_RetryCount ="CACHE_API_RetryCount";
/**
*API010自动retry的间隔(seconds)
*/
public static final String CACHE_API_RetryInterval ="CACHE_API_RetryInterval";
}
......@@ -356,7 +356,10 @@ public class HttpHelper {
}
public static MicronResult postMicronJson(String url, Map<String, Object> params) throws ApiException {
public static MicronResult postMicronJson(String url, Map<String, Object> params ) throws ApiException {
return postMicronJson(url,params,60000);
}
public static MicronResult postMicronJson(String url, Map<String, Object> params,int timeOutMs) throws ApiException {
try {
if (ObjectUtil.isEmpty(url)) {
return new MicronResult();
......@@ -380,7 +383,7 @@ public class HttpHelper {
}
try {
CloseableHttpClient httpClient = HttpClients.createDefault();
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(CONNECTION_TIMEOUT).setConnectionRequestTimeout(60000).setSocketTimeout(60000).build();
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(CONNECTION_TIMEOUT).setConnectionRequestTimeout(timeOutMs).setSocketTimeout(timeOutMs).build();
httpPost.setConfig(requestConfig);
CloseableHttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
......
......@@ -175,7 +175,15 @@ public class DataCache {
}
return null;
}
public <T> T getCache(String cacheKey,T defValue) {
Object value = cacheMap.get(cacheKey);
if (value != null) {
return (T) value;
}else {
updateCache(cacheKey,defValue);
return defValue;
}
}
public OrderSetting getOrderSetting() {
OrderSetting orderSetting = getCache(Constants.CACHE_OrderSetting);
if (orderSetting == null) {
......
......@@ -100,6 +100,8 @@ public class SettingsController {
xrayTest=false;
dataCache.updateCache(Constants.CACHE_XRAY_TEST,xrayTest);
}
int retryCount=dataCache.getCache(Constants.CACHE_API_RetryCount,3);
int retryInterval=dataCache.getCache(Constants.CACHE_API_RetryInterval,30);
String micronAppAddr=dataCache.getCache(Constants.CACHE_Micron_AppAddr);
SysSettingsDto dto = new SysSettingsDto();
dto.setStartJob(startJob);
......@@ -115,6 +117,8 @@ public class SettingsController {
dto.setInputCheck(inputCheck);
dto.setXRayTest(xrayTest);
dto.setMicronAppAddr(micronAppAddr);
dto.setRetryCount(retryCount);
dto.setRetryInterval(retryInterval);
return dto;
}
......@@ -135,12 +139,14 @@ public class SettingsController {
dataCache.updateCache(Constants.CACHE_INPUT_CHECK,sysSettingsDto.isInputCheck());
dataCache.updateCache(Constants.CACHE_XRAY_TEST,sysSettingsDto.isXRayTest());
dataCache.updateCache(Constants.CACHE_Micron_AppAddr,sysSettingsDto.getMicronAppAddr());
dataCache.updateCache(Constants.CACHE_API_RetryInterval,sysSettingsDto.getRetryInterval());
dataCache.updateCache(Constants.CACHE_API_RetryCount,sysSettingsDto.getRetryCount());
log.info("更改系统设置:stopout=" + sysSettingsDto.isStopOut() + ",stopjob=" + sysSettingsDto.isStartJob() + ",sluggishDay=" + sysSettingsDto.getSluggishDay()
+ ",expiresDay=" + sysSettingsDto.getExpiresDay() + ",capacityWarn=" + sysSettingsDto.getCapacityWarn() + ",backUpMonth=" + sysSettingsDto.getBackUpMonth() +
" ,sameBarcodeSettings=" + sysSettingsDto.getSameBarcodeSettings()+", apiTest="+sysSettingsDto.isApiTest()+",xrayBypass="+sysSettingsDto.isXrayBypass()+
",expiredateVerify=" + sysSettingsDto.isExpiredateVerify()+",inputCheck="+sysSettingsDto.isInputCheck()+",isXRayTest="+sysSettingsDto.isXRayTest()
+",CACHE_Micron_AppAddr="+sysSettingsDto.getMicronAppAddr());
+",CACHE_Micron_AppAddr="+sysSettingsDto.getMicronAppAddr()+", CACHE_API_RetryCount="+sysSettingsDto.getRetryCount()+", CACHE_API_RetryInterval="+sysSettingsDto.getRetryInterval());
micronConfig.UpdateAddr(sysSettingsDto.getMicronAppAddr());
String msg = MessageUtils.getText("smfcore.saveOk", servletRequest.getLocale(), "保存成功");
return ResultBean.newOkResult(msg);
......
......@@ -48,4 +48,8 @@ public class SysSettingsDto implements Serializable {
@ApiModelProperty("Xray点料测试功能")
private boolean xRayTest = false;
@ApiModelProperty("API010retry次数")
private int retryCount = 3;
@ApiModelProperty("API010retry间隔")
private int retryInterval = 30;
}
......@@ -25,6 +25,12 @@ public class TrackStatus implements Serializable {
private String serialNum;
private String partNumber;
private String materialStatus;
private boolean Success;
// private boolean Success;
private boolean sapSuccess;
private boolean mesSuccess;
private String description;
public boolean isSuccess(){
return isMesSuccess()&&isSapSuccess();
}
}
......@@ -207,6 +207,16 @@ public class MicronResult implements Serializable {
public static String GetMapValue(Map<String,Object> map,String key){
Object obj =map.get(key);
if(obj==null){
for (String mapKey :
map.keySet()) {
if( ObjectUtil.isNotEmpty(mapKey)&&ObjectUtil.isNotEmpty(key)&& mapKey.toLowerCase().equals(key.toLowerCase())) {
obj = map.get(mapKey);
if (ObjectUtil.isNotEmpty(obj)) {
return obj.toString();
}
}
}
return "";
}
return obj.toString();
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!