Procházet zdrojové kódy

风机相关代码提交

wangchangsheng před 2 roky
rodič
revize
b8fd7dac7f

+ 108 - 2
web/backmanagerconfig/src/main/java/com/gyee/backconfig/controller/WindturbineController.java

@@ -1,9 +1,14 @@
 package com.gyee.backconfig.controller;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.gyee.backconfig.config.R;
+import com.gyee.backconfig.model.auto.Windturbine;
+import com.gyee.backconfig.service.auto.IWindturbineService;
+import com.gyee.common.model.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
 
-import org.springframework.web.bind.annotation.RestController;
+import java.util.List;
 
 /**
  * <p>
@@ -17,4 +22,105 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("//windturbine")
 public class WindturbineController {
 
+    @Autowired
+    private IWindturbineService windturbineService;
+
+
+    /**
+     * 查询
+     * @param id
+     * @param code
+     * @param stationid
+     * @param projectid
+     * @param lineid
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    @GetMapping(value = "/companys")
+    public R findList(@RequestParam(value = "id", required = false) String id,
+                      @RequestParam(value = "code", required = false) String code,
+                      @RequestParam(value = "stationid", required = false) String stationid,
+                      @RequestParam(value = "projectid", required = false) String projectid,
+                      @RequestParam(value = "lineid", required = false) String lineid,
+                      @RequestParam(value = "pageNum", required = true) String pageNum,
+                      @RequestParam(value = "pageSize", required = true) String pageSize) {
+        List<Windturbine> list = windturbineService.list(id, code, stationid, projectid, lineid, pageNum, pageSize);
+        if (StringUtils.isNotEmpty(list)) {
+            return R.ok(list.size()).data(list);
+        } else {
+            return R.error().data("查询失败!");
+        }
+    }
+
+
+    /**
+     * 根据id查询
+     * @param id
+     * @return
+     */
+    @GetMapping(value = "/{id}")
+    public R findOne(@PathVariable("id") String id){
+
+        Windturbine windturbine = windturbineService.getOne(id);
+        if (StringUtils.isNotNull(windturbine)){
+            return R.ok().data(windturbine);
+        }else {
+            return R.error().data("查询失败!");
+        }
+
+    }
+
+
+    /**
+     * 插入(批量)
+     * @param windturbine
+     * @return
+     */
+    @PostMapping(value = "/add")
+    public R addAll(@RequestBody Windturbine windturbine){
+
+        boolean b = windturbineService.addOrUpdate(windturbine);
+        if (b){
+            return R.ok().data(b);
+        }else {
+            return R.error().data("保存失败!");
+        }
+
+    }
+
+
+
+    /**
+     * 批量删除
+     * @param ids
+     * @return
+     */
+    @DeleteMapping(value = "/{ids}")
+    public  R deleteAll(@PathVariable("ids") String ids){
+        boolean b = windturbineService.removeByIds(ids);
+        if (b){
+            return R.ok().data(b);
+        }else {
+            return R.error().data("删除失败!");
+        }
+    }
+
+    /**
+     * 批量修改
+     * @param list
+     * @return
+     */
+    @PutMapping(value = "/editRegions")
+    public R update(@RequestBody List<Windturbine> list){
+        boolean b = windturbineService.updateBatchById(list);
+        if (b){
+            return R.ok().data(b);
+        }else {
+            return R.error().data("更新失败!");
+        }
+
+    }
+
+
 }

+ 12 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/service/auto/IWindturbineService.java

@@ -3,6 +3,8 @@ package com.gyee.backconfig.service.auto;
 import com.gyee.backconfig.model.auto.Windturbine;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * <p>
  *  服务类
@@ -13,4 +15,14 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IWindturbineService extends IService<Windturbine> {
 
+
+    List<Windturbine> list(String id, String code,String stationid, String projectid, String lineid,String pageNum, String pageSize);
+
+    Windturbine getOne(String id);
+
+    boolean addOrUpdate(Windturbine windturbine);
+
+    boolean  removeByIds(String ids);
+
+
 }

+ 1 - 1
web/backmanagerconfig/src/main/java/com/gyee/backconfig/service/auto/impl/WindpowerstationServiceImpl.java

@@ -62,7 +62,7 @@ public class WindpowerstationServiceImpl extends ServiceImpl<WindpowerstationMap
 
     @Override
     public boolean addOrUpdate(Windpowerstation windpowerstation) {
-       boolean b =  this.saveOrUpdate(windpowerstation);
+        boolean b = this.saveOrUpdate(windpowerstation);
         return b;
     }
 

+ 56 - 0
web/backmanagerconfig/src/main/java/com/gyee/backconfig/service/auto/impl/WindturbineServiceImpl.java

@@ -1,11 +1,17 @@
 package com.gyee.backconfig.service.auto.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gyee.backconfig.model.auto.Windturbine;
 import com.gyee.backconfig.mapper.auto.WindturbineMapper;
 import com.gyee.backconfig.service.auto.IWindturbineService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.common.model.StringUtils;
 import org.springframework.stereotype.Service;
 
+import java.util.Arrays;
+import java.util.List;
+
 /**
  * <p>
  *  服务实现类
@@ -17,4 +23,54 @@ import org.springframework.stereotype.Service;
 @Service
 public class WindturbineServiceImpl extends ServiceImpl<WindturbineMapper, Windturbine> implements IWindturbineService {
 
+    @Override
+    public List<Windturbine> list(String id, String code, String stationid, String projectid, String lineid, String pageNum, String pageSize) {
+        QueryWrapper<Windturbine> qw = new QueryWrapper<>();
+        if (StringUtils.isNotEmpty(id)){
+            qw.eq("id",id);
+        }
+        if (StringUtils.isNotEmpty(code)){
+            qw.like("code",code);
+        }
+
+        if (StringUtils.isNotEmpty(stationid)){
+            qw.eq("windpowerstationid",stationid);
+        }
+
+        if (StringUtils.isNotEmpty(projectid)){
+            qw.eq("projectid",projectid);
+        }
+
+        if (StringUtils.isNotEmpty(lineid)){
+            qw.eq("lineid",lineid);
+        }
+
+        Page<Windturbine> page = new Page<>(Integer.parseInt(pageNum),Integer.parseInt(pageSize));
+        Page<Windturbine> companysPage = getBaseMapper().selectPage(page, qw);
+        List<Windturbine> list = companysPage.getRecords();
+        return list;
+    }
+
+    @Override
+    public Windturbine getOne(String id) {
+
+        Windturbine windturbine =  this.getById(id);
+        return windturbine;
+
+    }
+
+    @Override
+    public boolean addOrUpdate(Windturbine windturbine) {
+        boolean b = this.saveOrUpdate(windturbine);
+        return b;
+    }
+
+    @Override
+    public boolean removeByIds(String ids) {
+        String[] strings = ids.split(",");
+        boolean b = this.removeByIds(Arrays.asList(strings));
+        return b;
+    }
+
+
 }