Explorar o código

新增 一张图数字农田 获取天气信息接口

zhaiyifei hai 8 meses
pai
achega
f7115ff66e

+ 21 - 0
src/main/java/com/yunfeiyun/agmp/fms/controller/FmsScreenController.java

@@ -1,10 +1,13 @@
 package com.yunfeiyun.agmp.fms.controller;
 
+import com.alibaba.fastjson2.JSONObject;
+import com.nlf.calendar.Lunar;
 import com.yunfeiyun.agmp.common.constant.ErrorCode;
 import com.yunfeiyun.agmp.common.core.controller.BaseController;
 import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
 import com.yunfeiyun.agmp.common.core.page.TableDataInfo;
 import com.yunfeiyun.agmp.common.exception.BizException;
+import com.yunfeiyun.agmp.common.service.WeatherService;
 import com.yunfeiyun.agmp.common.utils.SecurityUtils;
 import com.yunfeiyun.agmp.common.utils.StringUtils;
 import com.yunfeiyun.agmp.fms.domain.FmsBlock;
@@ -45,6 +48,9 @@ public class FmsScreenController extends BaseController {
     @Autowired
     private IFmsWarnService fmsWarnService;
 
+    @Autowired
+    private WeatherService weatherService;
+
     /**
      * 查询基地列表不分页
      */
@@ -174,4 +180,19 @@ public class FmsScreenController extends BaseController {
         List<FmsWarnResVo> list = fmsWarnService.selectFmsWarnList(fmsWarnReqVo);
         return getDataTable(list);
     }
+
+    /**
+     * 查询天气信息
+     * */
+
+    @GetMapping("/weather/info")
+    public AjaxResult weatherInfo() {
+        JSONObject result = weatherService.getProjectWeather();
+        if(result == null){
+            throw new BizException(ErrorCode.SYSTEM_ERROR);
+        }
+        Lunar chineseCalendar = new Lunar();
+        result.put("chineseCalendar",chineseCalendar.getMonthInChinese()+"月"+chineseCalendar.getDayInChinese());
+        return success(result);
+    }
 }