Browse Source

气象站配置方法添加

wangchangsheng 2 years ago
parent
commit
5a61837ae3

+ 86 - 2
web/backmanagerconfig-xktj/src/main/java/com/gyee/backconfig/controller/ProBasicWeatherStationController.java

@@ -1,9 +1,18 @@
 package com.gyee.backconfig.controller;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gyee.backconfig.config.R;
+import com.gyee.backconfig.model.auto.ProBasicWeatherStation;
+import com.gyee.backconfig.service.auto.IProBasicWeatherStationService;
+import com.gyee.common.model.StringUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
 
-import org.springframework.web.bind.annotation.RestController;
+import java.util.Arrays;
 
 /**
  * <p>
@@ -15,6 +24,81 @@ import org.springframework.web.bind.annotation.RestController;
  */
 @RestController
 @RequestMapping("//pro-basic-weather-station")
+@Api(value = "气象站配置" ,tags =  "气象站配置")
 public class ProBasicWeatherStationController {
 
+    @Autowired
+    private IProBasicWeatherStationService proBasicWeatherStationService;
+
+
+    @GetMapping(value = "/List")
+    @ApiOperation(value = "气象站-列表", notes = "气象站-列表")
+    public R findList(@RequestParam(value = "id", required = false) String id,
+                      @RequestParam(value = "code", required = false) String code,
+                      @RequestParam(value = "name", required = false) String name,
+                      @RequestParam(value = "stationId", required = false) String stationId,
+                      @RequestParam(value = "pageNum", required = true) String pageNum,
+                      @RequestParam(value = "pageSize", required = true) String pageSize) {
+        IPage<ProBasicWeatherStation> list = proBasicWeatherStationService.list(id, name,stationId, code, pageNum, pageSize);
+        if (null != list) {
+            return R.ok().data(list);
+        } else {
+            return R.error().data("查询失败!");
+        }
+    }
+
+
+    /**
+     * 根据id查询
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping(value = "/weather/{id}")
+    @ApiOperation(value = "气象站-根据主键查询", notes = "气象站-根据主键查询")
+    public R findOne(@RequestParam("id") String id) {
+        QueryWrapper<ProBasicWeatherStation> qw = new QueryWrapper<>();
+        qw.eq("id", id);
+        ProBasicWeatherStation weatherStation = proBasicWeatherStationService.getOne(qw);
+        if (StringUtils.isNotNull(weatherStation)) {
+            return R.ok().data(weatherStation);
+        } else {
+            return R.error().data("查询失败!");
+        }
+    }
+
+    /**
+     * 批量插入
+     *
+     * @param weatherStation
+     * @return
+     */
+    @PostMapping(value = "/save")
+    @ApiOperation(value = "气象站-新增or修改", notes = "气象站-新增or修改")
+    public R addAll(@RequestBody ProBasicWeatherStation weatherStation) {
+        boolean b = proBasicWeatherStationService.saveOrUpdate(weatherStation);
+        if (b) {
+            return R.ok().data(b);
+        } else {
+            return R.error().data("保存失败!");
+        }
+    }
+
+    /**
+     * 删除
+     *
+     * @param ids
+     * @return
+     */
+    @DeleteMapping(value = "/remove-weather-station/{ids}")
+    @ApiOperation(value = "气象站-删除", notes = "气象站-删除")
+    public R deleteAll(@PathVariable("ids") String ids) {
+        String[] strings = ids.split(",");
+        boolean b = proBasicWeatherStationService.removeByIds(Arrays.asList(strings));
+        if (b) {
+            return R.ok().data(b);
+        } else {
+            return R.error().data("删除失败!");
+        }
+    }
 }

+ 1 - 1
web/backmanagerconfig-xktj/src/main/java/com/gyee/backconfig/controller/ProEconTestingPointController.java

@@ -144,7 +144,7 @@ public class ProEconTestingPointController {
     }
 
 
-    @PostMapping(value = "/generateWsStationPoint")
+    @PostMapping(value = "/generateSquareStationPoint")
     @ApiOperation(value = "光伏阵区测点生成", notes = "光伏阵区测点生成")
     public R generateSquareStationPoint(@RequestParam(value = "points", required = false) String[] points,
                                     @RequestParam(value = "station", required = false) String station) {

+ 3 - 0
web/backmanagerconfig-xktj/src/main/java/com/gyee/backconfig/service/auto/IProBasicWeatherStationService.java

@@ -1,5 +1,6 @@
 package com.gyee.backconfig.service.auto;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.gyee.backconfig.model.auto.ProBasicWeatherStation;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -13,4 +14,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IProBasicWeatherStationService extends IService<ProBasicWeatherStation> {
 
+    IPage<ProBasicWeatherStation> list(String id, String name, String stationId, String code, String pageNum, String pageSize);
+
 }

+ 29 - 0
web/backmanagerconfig-xktj/src/main/java/com/gyee/backconfig/service/auto/impl/ProBasicWeatherStationServiceImpl.java

@@ -1,9 +1,13 @@
 package com.gyee.backconfig.service.auto.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gyee.backconfig.model.auto.ProBasicWeatherStation;
 import com.gyee.backconfig.mapper.auto.ProBasicWeatherStationMapper;
 import com.gyee.backconfig.service.auto.IProBasicWeatherStationService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.common.model.StringUtils;
 import org.springframework.stereotype.Service;
 
 /**
@@ -17,4 +21,29 @@ import org.springframework.stereotype.Service;
 @Service
 public class ProBasicWeatherStationServiceImpl extends ServiceImpl<ProBasicWeatherStationMapper, ProBasicWeatherStation> implements IProBasicWeatherStationService {
 
+    @Override
+    public IPage<ProBasicWeatherStation> list(String id, String name, String stationId, String code, String pageNum, String pageSize) {
+        QueryWrapper<ProBasicWeatherStation> qw = new QueryWrapper<>();
+
+        if (StringUtils.isNotEmpty(id)){
+            qw.eq("id",id);
+        }
+
+        if (StringUtils.isNotEmpty(name)){
+            qw.like("name",name);
+        }
+        if (StringUtils.isNotEmpty(stationId)){
+            qw.eq("windpowerstation_id",stationId);
+        }
+
+
+        if (StringUtils.isNotEmpty(code)){
+            qw.like("code",code);
+        }
+
+
+        Page<ProBasicWeatherStation> page = new Page<>(Integer.parseInt(pageNum),Integer.parseInt(pageSize));
+        IPage<ProBasicWeatherStation> pageData = baseMapper.selectPage(page, qw);
+        return pageData;
+    }
 }