|
|
@@ -18,14 +18,13 @@ import com.usoftchina.saas.utils.ObjectUtils;
|
|
|
import com.usoftchina.saas.utils.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
-import org.springframework.util.LinkedMultiValueMap;
|
|
|
-import org.springframework.util.MultiValueMap;
|
|
|
+import org.springframework.web.client.HttpServerErrorException;
|
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.*;
|
|
|
-import java.util.function.Consumer;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -87,7 +86,11 @@ public class ApCheckServiceImpl implements ApCheckService {
|
|
|
response.put("content", result);
|
|
|
response.put("totalElement", result.size());
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
+ } catch (HttpServerErrorException e) {
|
|
|
+ HttpServerErrorException httpServerErrorException = (HttpServerErrorException) e;
|
|
|
+ String responseText = httpServerErrorException.getResponseBodyAsString();
|
|
|
+ throw new BizException(80000, responseText);
|
|
|
+ } catch (Exception e){
|
|
|
throw new BizException(80000, e.getMessage());
|
|
|
}
|
|
|
return response;
|
|
|
@@ -132,7 +135,13 @@ public class ApCheckServiceImpl implements ApCheckService {
|
|
|
result.put("items", apCheckProdIO.getDetails().stream().filter(apCheckProdIODetail -> currency.equals(apCheckProdIODetail.getCurrency())).collect(Collectors.toList()));
|
|
|
result.put("data", apCheckProdIO);
|
|
|
} catch (Exception e) {
|
|
|
- throw new BizException(80000, e.getMessage());
|
|
|
+ if (e instanceof HttpServerErrorException){
|
|
|
+ HttpServerErrorException httpServerErrorException = (HttpServerErrorException) e;
|
|
|
+ String responseText = httpServerErrorException.getResponseBodyAsString();
|
|
|
+ throw new BizException(80000, responseText);
|
|
|
+ }else {
|
|
|
+ throw new BizException(80000, e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
@@ -190,7 +199,7 @@ public class ApCheckServiceImpl implements ApCheckService {
|
|
|
public ModelMap operationSave(SaveOperationData saveOperationData) {
|
|
|
Result<AccountDTO> accountResult = accountApi.getAccountById(BaseContextHolder.getUserId());
|
|
|
Result<CompanyDTO> companyResult = companyApi.getCompanyById(BaseContextHolder.getCompanyId());
|
|
|
- ModelMap result = null;
|
|
|
+ ResponseEntity<String> responseEntity = null;
|
|
|
if (accountResult.isSuccess() && companyResult.isSuccess()) {
|
|
|
Long userUU = accountResult.getData().getUu();
|
|
|
Long enUU = companyResult.getData().getUu();
|
|
|
@@ -202,12 +211,21 @@ public class ApCheckServiceImpl implements ApCheckService {
|
|
|
//String url = "http://10.1.51.139:8889" + SAVEAPCHECKURL;
|
|
|
saveOperationData.setEnUu(enUU);
|
|
|
try {
|
|
|
- result = AccessUtils.postForObject(url, account, ModelMap.class, URLEncoder.encode(JsonUtils.toJsonString(saveOperationData), "UTF-8"));
|
|
|
+ responseEntity = AccessUtils.postForEntity(url, account, URLEncoder.encode(JsonUtils.toJsonString(saveOperationData), "UTF-8"));
|
|
|
} catch (Exception e){
|
|
|
- throw new BizException(80000, e.getMessage());
|
|
|
+ if (e instanceof HttpServerErrorException){
|
|
|
+ HttpServerErrorException httpServerErrorException = (HttpServerErrorException) e;
|
|
|
+ String responseText = httpServerErrorException.getResponseBodyAsString();
|
|
|
+ if (responseText.startsWith("无法对账!(该客户未对您启用B2B对账")) {
|
|
|
+ responseText = "无法对账!该客户未对您启用B2B对账,请让客户在“U企云服-UU设置”里获取UU后再进行对账。";
|
|
|
+ }
|
|
|
+ throw new BizException(80000, responseText);
|
|
|
+ }else {
|
|
|
+ throw new BizException(80000, e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- return result;
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -227,7 +245,13 @@ public class ApCheckServiceImpl implements ApCheckService {
|
|
|
response.remove("items");
|
|
|
result.put("main", response);
|
|
|
} catch (Exception e){
|
|
|
- throw new BizException(80000, e.getMessage());
|
|
|
+ if (e instanceof HttpServerErrorException){
|
|
|
+ HttpServerErrorException httpServerErrorException = (HttpServerErrorException) e;
|
|
|
+ String responseText = httpServerErrorException.getResponseBodyAsString();
|
|
|
+ throw new BizException(80000, responseText);
|
|
|
+ }else {
|
|
|
+ throw new BizException(80000, e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
@@ -249,7 +273,13 @@ public class ApCheckServiceImpl implements ApCheckService {
|
|
|
}
|
|
|
result = AccessUtils.getForObject(url, account, SPage.class);
|
|
|
} catch (Exception e) {
|
|
|
- throw new BizException(80000, e.getMessage());
|
|
|
+ if (e instanceof HttpServerErrorException){
|
|
|
+ HttpServerErrorException httpServerErrorException = (HttpServerErrorException) e;
|
|
|
+ String responseText = httpServerErrorException.getResponseBodyAsString();
|
|
|
+ throw new BizException(80000, responseText);
|
|
|
+ }else {
|
|
|
+ throw new BizException(80000, e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
return result;
|
|
|
}
|