|
|
@ -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,32 +197,36 @@ 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()); |
|
|
|
JSONArray we_date=new JSONArray(); |
|
|
|
JSONArray we_name=new JSONArray(); |
|
|
|
JSONArray tem_day=new JSONArray(); |
|
|
|
JSONArray tem_night=new JSONArray(); |
|
|
|
we_date.add("天气日期:"); |
|
|
|
we_name.add("天气情况:"); |
|
|
|
tem_day.add("日间气温:"); |
|
|
|
tem_night.add("夜间气温:"); |
|
|
|
weatherInfo.forEach(item->{ |
|
|
|
JSONObject jsb=JSONObject.from(item); |
|
|
|
we_date.add(jsb.getString("date")); |
|
|
|
tem_day.add(jsb.getString("tem_day")); |
|
|
|
tem_night.add(jsb.getString("tem_night")); |
|
|
|
we_name.add(jsb.getString("wea")); |
|
|
|
}); |
|
|
|
JSONArray list=new JSONArray(); |
|
|
|
list.add(we_date); |
|
|
|
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)); |
|
|
|
if (null != weatherInfo && !weatherInfo.isEmpty()) { |
|
|
|
JSONArray we_date=new JSONArray(); |
|
|
|
JSONArray we_name=new JSONArray(); |
|
|
|
JSONArray tem_day=new JSONArray(); |
|
|
|
JSONArray tem_night=new JSONArray(); |
|
|
|
we_date.add("天气日期:"); |
|
|
|
we_name.add("天气情况:"); |
|
|
|
tem_day.add("日间气温:"); |
|
|
|
tem_night.add("夜间气温:"); |
|
|
|
weatherInfo.forEach(item->{ |
|
|
|
JSONObject jsb=JSONObject.from(item); |
|
|
|
we_date.add(jsb.getString("date")); |
|
|
|
tem_day.add(jsb.getString("tem_day")); |
|
|
|
tem_night.add(jsb.getString("tem_night")); |
|
|
|
we_name.add(jsb.getString("wea")); |
|
|
|
}); |
|
|
|
JSONArray list=new JSONArray(); |
|
|
|
list.add(we_date); |
|
|
|
list.add(tem_day); |
|
|
|
list.add(tem_night); |
|
|
|
list.add(we_name); |
|
|
|
ret.put("source",list); |
|
|
|
ret.put("realwe",weatherInfo.get(0)); |
|
|
|
} else { |
|
|
|
log.error("天气接口未返回数据"); |
|
|
|
} |
|
|
|
return AjaxResult.success(ret); |
|
|
|
} |
|
|
|
/** |
|
|
|