提交地图修改内容
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package com.njcn.echarts.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.echarts.pojo.enums.EchartResponseEnum;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年08月18日 10:27
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class DrawPicUtil {
|
||||
|
||||
private final RestTemplate restTemplate;
|
||||
|
||||
|
||||
/**
|
||||
* 请求目标服务器绘制echart图
|
||||
* @param url 目标url,例:http://192.168.1.13:8910?opt={1}&width={2}&height={3}
|
||||
* @param option 图形参数
|
||||
* @param width 图形宽度
|
||||
* @param height 图形高度
|
||||
* @return 图形的base64数据
|
||||
*/
|
||||
public String drawPic(String url,String option,int width,int height){
|
||||
ResponseEntity<HttpResult> result = restTemplate.getForEntity(url, HttpResult.class, option, width, height);
|
||||
if(result.getStatusCodeValue() != HttpStatus.HTTP_OK || Objects.isNull(Objects.requireNonNull(result.getBody()).getData())){
|
||||
throw new BusinessException(EchartResponseEnum.ECHART_COMMON_ERROR);
|
||||
}
|
||||
return result.getBody().getData().toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user