Browse Source

增加汇流箱配置

wangb 2 years ago
parent
commit
3da488de7c

+ 64 - 3
web/backmanagerconfig/src/main/java/com/gyee/backconfig/controller/JunctionboxController.java

@@ -1,12 +1,15 @@
 package com.gyee.backconfig.controller;
 
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gyee.backconfig.config.R;
+import com.gyee.backconfig.model.auto.Inverter;
+import com.gyee.backconfig.model.auto.Junctionbox;
 import com.gyee.backconfig.service.auto.IJunctionboxService;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.util.Arrays;
 
 /**
  * <p>
@@ -22,4 +25,62 @@ public class JunctionboxController {
     @Resource
     private IJunctionboxService junctionboxService;
 
+    /**
+     * 查询
+     * @param id
+     * @param code
+     * @param windpowerstationid
+     * @param inverterid
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    @GetMapping(value = "/listByPage")
+    public R findList(@RequestParam(value = "id", required = false) String id,
+                      @RequestParam(value = "code", required = false) String code,
+                      @RequestParam(value = "windpowerstationid", required = false) String windpowerstationid,
+                      @RequestParam(value = "inverterid", required = false) String inverterid,
+                      @RequestParam(value = "pageNum", required = true) String pageNum,
+                      @RequestParam(value = "pageSize", required = true) String pageSize) {
+        IPage<Junctionbox> list = junctionboxService.list(id, code, windpowerstationid, inverterid, pageNum, pageSize);
+        if (null != list) {
+            return R.ok().data(list);
+        } else {
+            return R.error().data("查询失败!");
+        }
+    }
+
+    /**
+     * 插入
+     *
+     * @param junctionbox
+     * @return
+     */
+    @PostMapping(value = "/save")
+    public R addAll(@RequestBody Junctionbox junctionbox) {
+        boolean b = junctionboxService.saveOrUpdate(junctionbox);
+        if (b) {
+            return R.ok().data(b);
+        } else {
+            return R.error().data("保存失败!");
+        }
+    }
+
+    /**
+     * 删除
+     *
+     * @param ids
+     * @return
+     */
+    @DeleteMapping(value = "/remove-junctionbox/{ids}")
+    public R deleteAll(@PathVariable("ids") String ids) {
+        String[] strings = ids.split(",");
+        boolean b = junctionboxService.removeByIds(Arrays.asList(strings));
+        if (b) {
+            return R.ok().data(b);
+        } else {
+            return R.error().data("删除失败!");
+        }
+    }
+
 }

+ 3 - 1
web/backmanagerconfig/src/main/java/com/gyee/backconfig/service/auto/IJunctionboxService.java

@@ -1,5 +1,7 @@
 package com.gyee.backconfig.service.auto;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gyee.backconfig.model.auto.Inverter;
 import com.gyee.backconfig.model.auto.Junctionbox;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -12,5 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @since 2022-10-17
  */
 public interface IJunctionboxService extends IService<Junctionbox> {
-
+    IPage<Junctionbox> list(String id, String code, String windpowerstationid, String inverterid, String pageNum, String pageSize);
 }

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

@@ -1,9 +1,14 @@
 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.Inverter;
 import com.gyee.backconfig.model.auto.Junctionbox;
 import com.gyee.backconfig.mapper.auto.JunctionboxMapper;
 import com.gyee.backconfig.service.auto.IJunctionboxService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.common.model.StringUtils;
 import org.springframework.stereotype.Service;
 
 /**
@@ -17,4 +22,23 @@ import org.springframework.stereotype.Service;
 @Service
 public class JunctionboxServiceImpl extends ServiceImpl<JunctionboxMapper, Junctionbox> implements IJunctionboxService {
 
+    @Override
+    public IPage<Junctionbox> list(String id, String code, String windpowerstationid, String inverterid, String pageNum, String pageSize) {
+        QueryWrapper<Junctionbox> qw = new QueryWrapper<>();
+        if (StringUtils.isNotEmpty(id)) {
+            qw.like("id", id);
+        }
+        if (StringUtils.isNotEmpty(code)) {
+            qw.like("code", code);
+        }
+        if (StringUtils.isNotEmpty(windpowerstationid)) {
+            qw.like("windpowerstationid", windpowerstationid);
+        }
+        if (StringUtils.isNotEmpty(inverterid)) {
+            qw.like("inverterid", inverterid);
+        }
+        Page<Junctionbox> page = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
+        IPage<Junctionbox> Inverter =getBaseMapper().selectPage(page, qw);
+        return Inverter;
+    }
 }