Browse Source

1、天气接口加个判断

develop
bobol 9 months ago
parent
commit
73c2ca4cfd
  1. 8
      lzbi-module/src/main/java/com/lzbi/bi/controller/DcBusiDataScreenMainController.java

8
lzbi-module/src/main/java/com/lzbi/bi/controller/DcBusiDataScreenMainController.java

@ -15,6 +15,7 @@ import com.lzbi.common.core.domain.entity.SysDept;
import com.lzbi.common.utils.StringUtils;
import com.lzbi.system.service.impl.SysDeptServiceImpl;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.lang.Nullable;
@ -31,6 +32,7 @@ import java.util.concurrent.atomic.AtomicReference;
* @author : zhousq
* @date : 2023-11-16
*/
@Slf4j
@Api(tags = "主数据大屏的页面接口")
@RestController
@RequestMapping("/assetData/dataScreenMain")
@ -195,9 +197,11 @@ public class DcBusiDataScreenMainController extends BaseController{
String yikeapiAppsecret;
@GetMapping("/weather/{areaCode}")
public AjaxResult getWeather(@PathVariable String areaCode){
JSONObject ret=new JSONObject();
String url=StrUtil.format("https://v1.yiketianqi.com/free/week?city=沈阳&unescape=1&appid={}&appsecret={}",yikeapiAppid,yikeapiAppsecret);
JSONObject weather=JSONObject.parseObject(HttpUtil.get(url));
JSONArray weatherInfo=Optional.ofNullable(weather.getJSONArray("data")).orElse(new JSONArray());
if (null != weatherInfo && !weatherInfo.isEmpty()) {
JSONArray we_date=new JSONArray();
JSONArray we_name=new JSONArray();
JSONArray tem_day=new JSONArray();
@ -218,9 +222,11 @@ public class DcBusiDataScreenMainController extends BaseController{
list.add(tem_day);
list.add(tem_night);
list.add(we_name);
JSONObject ret=new JSONObject();
ret.put("source",list);
ret.put("realwe",weatherInfo.get(0));
} else {
log.error("天气接口未返回数据");
}
return AjaxResult.success(ret);
}
/**

Loading…
Cancel
Save