网络错误异常捕捉,诏安第三方仓库信息返回转换为一个仓库多个分库返回,

master
anthonyywj2 3 years ago
parent 99faf1988c
commit 742072f1cb

@ -41,6 +41,8 @@ import com.glxp.mipsdl.admin.req.phxyy.PhProductRequest;
import com.glxp.mipsdl.admin.req.phxyy.PhUnitRequest;
import com.glxp.mipsdl.admin.req.phxyy.PhWarehouseRequest;
import com.glxp.mipsdl.admin.req.thrsys.FilterThrInvWarehouseRequest;
import com.glxp.mipsdl.admin.res.system.PageSimpleResponse;
import com.glxp.mipsdl.admin.res.system.UdiwmsWarehouseDetail;
import com.glxp.mipsdl.admin.util.DateUtil;
import com.glxp.mipsdl.admin.util.HttpClient;
import com.glxp.mipsdl.common.res.BaseResponse;
@ -378,14 +380,6 @@ public class ZaxyyClient {
BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailDao.selectByOrderType(key, thirdSysConfig.getThirdSysConfig().getThirdId(), udiwmsOrderRequest.getBillType());
String interStr = "";
if (StrUtil.isNotEmpty(basicThirdSysDetailEntity.getOrderTypeUrl())) {
interStr = basicThirdSysDetailEntity.getOrderTypeUrl();
} else {
interStr = basicThirdSysDetailEntity.getValue();
}
//记录日志
StockOrderUploadLogEntity uploadLog = new StockOrderUploadLogEntity();
uploadLog.setBillDate(DateUtil.parseDate(udiwmsOrderRequest.getBillDate()));
@ -393,7 +387,7 @@ public class ZaxyyClient {
uploadLog.setSubmitTime(new Date());
uploadLog.setBillNo(udiwmsOrderRequest.getBillNo());
uploadLog.setFromType(ConstantStatus.THIRD_ORDER_UPLOAD);
String response = httpClient.postJson(thirdSysConfig.getThirdSysConfig().getThirdSysUrl() + interStr, zaZyHeareRequest, getHeaderArray());
String response = httpClient.postJson(thirdSysConfig.getThirdSysConfig().getThirdSysUrl(), zaZyHeareRequest, getHeaderArray());
response = parseErrorMsg(response);
if (StrUtil.isNotBlank(response)) {
try {
@ -483,12 +477,33 @@ public class ZaxyyClient {
String response = httpClient.postJson(thirdSysConfig.getThirdSysConfig().getThirdSysUrl() + basicThirdSysDetailEntity.getValue(), zaZyHeareRequest, getHeaderArray());
response = parseErrorMsg(response);
try {
BaseResponse baseResponse =
BaseResponse<PageSimpleResponse<UdiwmsWarehouseDetail>> baseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse>() {
});
if (baseResponse.getCode() == 20000) {
List<UdiwmsWarehouseDetail> udiwmsWarehouseDetails = baseResponse.getData().getList();
UdiwmsWarehouseDetail resultData = new UdiwmsWarehouseDetail();
if (CollUtil.isNotEmpty(udiwmsWarehouseDetails)) {
resultData.setCode("7071568");
resultData.setCode("总仓库");
List<UdiwmsWarehouseDetail.SubWarehouse> subWarehouseList = new ArrayList<>();
for (UdiwmsWarehouseDetail udiwmsWarehouseDetail : udiwmsWarehouseDetails) {
UdiwmsWarehouseDetail.SubWarehouse subWarehouse = new UdiwmsWarehouseDetail.SubWarehouse();
subWarehouse.setCode(udiwmsWarehouseDetail.getCode());
subWarehouse.setName(udiwmsWarehouseDetail.getName());
subWarehouseList.add(subWarehouse);
}
resultData.setSubWarehouses(subWarehouseList);
}
List<UdiwmsWarehouseDetail> resultList = new ArrayList<>();
resultList.add(resultData);
PageSimpleResponse<UdiwmsWarehouseDetail> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(1L);
pageSimpleResponse.setList(resultList);
return ResultVOUtils.success(pageSimpleResponse);
}
return baseResponse;
} catch (
Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果" + "" + response + ")");

@ -2,6 +2,8 @@ package com.glxp.mipsdl.admin.res.system;
import lombok.Data;
import java.util.List;
@Data
public class UdiwmsWarehouseDetail {
@ -13,4 +15,20 @@ public class UdiwmsWarehouseDetail {
//备注
private String remark;
private List<SubWarehouse> subWarehouses;
@Data
public static class SubWarehouse {
//货位号
private String code;
//货位名称
private String name;
//备注
private String remark;
}
}

@ -1,6 +1,5 @@
package com.glxp.mipsdl.admin.util;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.glxp.mipsdl.admin.http.OkHttpCli;
import org.slf4j.Logger;
@ -69,11 +68,14 @@ public class HttpClient {
public String postJson(String url, Object object, String... headers) {
String json = JSONObject.toJSON(object).toString();
logger.info(url + "\n" + json);
String response = okHttpCli.doPostJson(url, json, headers);
logger.error(response);
if (StrUtil.isEmpty(response)) {
String response = "";
try {
response = okHttpCli.doPostJson(url, json, headers);
} catch (Exception e) {
response = "网络错误,或远程服务器无法异常,无法连接!";
}
logger.error(response);
return response;
}

Loading…
Cancel
Save