获取重量api接口测试1.1
This commit is contained in:
parent
681db4295d
commit
6ae3fac4e9
|
|
@ -3,6 +3,7 @@ package com.ruoyi.operation.service.impl;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||
import com.ruoyi.common.utils.DictUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.domain.SysConfig;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -27,7 +28,13 @@ public class getPoundWeightData {
|
|||
public BigDecimal getPoundWeight(@PathVariable("poundid")String poundid) {
|
||||
//根据地磅编码,在系统参数中获取接口地址,调用接口返回数据。
|
||||
String pound_api = DictUtils.getDictLabel("pound_api", poundid);
|
||||
if(StringUtils.isBlank(pound_api)){
|
||||
throw new RuntimeException("磅点api未维护!无法获取重量");
|
||||
}
|
||||
SysConfig sysConfig = sysConfigService.selectConfigByConfigKey("pound_api_ip");
|
||||
if(sysConfig==null){
|
||||
throw new RuntimeException("磅点api域名未维护!无法获取重量");
|
||||
}
|
||||
String api = sysConfig.getConfigValue()+pound_api;
|
||||
JSONObject jsonObject = doGetRequest(api);
|
||||
if (jsonObject.getIntValue("code") == 0) {
|
||||
|
|
@ -48,8 +55,8 @@ public class getPoundWeightData {
|
|||
connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setRequestProperty("Content-Type", "application/json; charset=utf-8");
|
||||
connection.setConnectTimeout(30000);
|
||||
connection.setReadTimeout(30000);
|
||||
connection.setConnectTimeout(20000);
|
||||
connection.setReadTimeout(20000);
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue