瀏覽代碼

代码优化

wangchangsheng 2 年之前
父節點
當前提交
ce1a2f1cc9

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

@@ -95,6 +95,7 @@ public class ProBasicEquipmentController {
         String[] strings = ids.split(",");
         boolean b = proBasicWindturbineService.removeByIds(Arrays.asList(strings));
         if (b) {
+            cacheContext.initEquipmentList();
             return R.ok().data(b);
         } else {
             return R.error().data("删除失败!");

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

@@ -88,6 +88,7 @@ public class ProBasicLineController {
         boolean  b = proBasicLineService.removeByIds(Arrays.asList(strings));
 
         if (b) {
+            cacheContext.initLineList();
             return R.ok().data(b);
         } else {
             return R.error().data("删除失败!");

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

@@ -93,6 +93,7 @@ public class ProBasicPowerstationController {
         String[] strings = ids.split(",");
         boolean b = proBasicWindpowerstationService.removeByIds(Arrays.asList(strings));
         if (b) {
+            cacheContext.initPowerstationList();
             return R.ok().data(b);
         } else {
             return R.error().data("删除失败!");

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

@@ -90,6 +90,7 @@ public class ProBasicProjectController {
         boolean  b = proBasicProjectService.removeByIds(Arrays.asList(strings));
 
         if (b) {
+            cacheContext.initProjectList();
             return R.ok().data(b);
         } else {
             return R.error().data("删除失败!");

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

@@ -83,6 +83,7 @@ public class ProBasicRegionController {
         String[] strings = ids.split(",");
         boolean b = proBasicRegionService.removeByIds(Arrays.asList(strings));
         if (b) {
+            cacheContext.initSegionList();
             return R.ok().data(b);
         } else {
             return R.error().data("删除失败!");

+ 79 - 2
web/backmanagerconfig-xktj/src/main/java/com/gyee/backconfig/controller/ProBasicSquareController.java

@@ -1,8 +1,17 @@
 package com.gyee.backconfig.controller;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gyee.backconfig.config.CacheContext;
+import com.gyee.backconfig.config.R;
+import com.gyee.backconfig.model.auto.ProBasicSquare;
+import com.gyee.backconfig.service.auto.IProBasicSquareService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.Arrays;
 
 /**
  * <p>
@@ -16,4 +25,72 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("//pro-basic-square")
 public class ProBasicSquareController {
 
+    @Resource
+    private IProBasicSquareService proBasicSquareService;
+    @Autowired
+    private CacheContext cacheContext;
+    /**
+     * 查询
+     *
+     * @param id
+     * @param
+     * @param name
+     * @param aname
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    @GetMapping(value = "/List")
+    @ApiOperation(value = "方阵-列表", notes = "方阵-列表")
+    public R findList(@RequestParam(value = "id", required = false) String id,
+                      @RequestParam(value = "name", required = false) String name,
+                      @RequestParam(value = "aname", required = false) String aname,
+                      @RequestParam(value = "nemCode", required = false) String nemCode,
+                      @RequestParam(value = "windpowerstationId", required = false) String windpowerstationId,
+                      @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) {
+        IPage<ProBasicSquare> list = proBasicSquareService.list(id, name, aname, nemCode, windpowerstationId,projectId,lineId,pageNum, pageSize);
+        if (null != list) {
+            return R.ok().data(list);
+        } else {
+            return R.error().data("查询失败!");
+        }
+    }
+
+    /**
+     * 保存
+     *
+     * @param proBasicRegion
+     * @return
+     */
+    @PostMapping(value = "/save")
+    @ApiOperation(value = "方阵-新增or修改", notes = "方阵-新增or修改")
+    @CrossOrigin(origins = "*", maxAge = 3600)
+    public R addAll(@RequestBody ProBasicSquare proBasicRegion) {
+
+        boolean b = proBasicSquareService.saveOrUpdate(proBasicRegion);
+        if (b) {
+            cacheContext.initSquaresList();
+            return R.ok().data(b);
+        } else {
+            return R.error().data("保存失败!");
+        }
+    }
+
+    @DeleteMapping(value = "/{ids}")
+    @ApiOperation(value = "方阵-删除", notes = "方阵-删除")
+    public R deleteAll(@PathVariable("ids") String ids) {
+        String[] strings = ids.split(",");
+        boolean b = proBasicSquareService.removeByIds(Arrays.asList(strings));
+        if (b) {
+            cacheContext.initSquaresList();
+            return R.ok().data(b);
+        } else {
+            return R.error().data("删除失败!");
+        }
+    }
+
+
 }

+ 7 - 0
web/backmanagerconfig-xktj/src/main/java/com/gyee/backconfig/controller/ProBasicSubStationController.java

@@ -3,12 +3,14 @@ package com.gyee.backconfig.controller;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gyee.backconfig.config.CacheContext;
 import com.gyee.backconfig.config.R;
 import com.gyee.backconfig.model.auto.ProBasicSubStation;
 import com.gyee.backconfig.service.auto.IProBasicSubStationService;
 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 javax.annotation.Resource;
@@ -29,6 +31,9 @@ public class ProBasicSubStationController {
     @Resource
     private IProBasicSubStationService proBasicWindsubStationService;
 
+    @Autowired
+    private CacheContext cacheContext;
+
     @GetMapping(value = "/List")
     @ApiOperation(value = "变电所-列表", notes = "变电所-列表")
     public R findList(@RequestParam(value = "id", required = false) String id,
@@ -75,6 +80,7 @@ public class ProBasicSubStationController {
     public R addAll(@RequestBody ProBasicSubStation meterpoint) {
         boolean b = proBasicWindsubStationService.saveOrUpdate(meterpoint);
         if (b) {
+            cacheContext.initSubStationList();
             return R.ok().data(b);
         } else {
             return R.error().data("保存失败!");
@@ -93,6 +99,7 @@ public class ProBasicSubStationController {
         String[] strings = ids.split(",");
         boolean b = proBasicWindsubStationService.removeByIds(Arrays.asList(strings));
         if (b) {
+            cacheContext.initSubStationList();
             return R.ok().data(b);
         } else {
             return R.error().data("删除失败!");

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

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

+ 37 - 0
web/backmanagerconfig-xktj/src/main/java/com/gyee/backconfig/service/auto/impl/ProBasicSquareServiceImpl.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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gyee.backconfig.mapper.auto.ProBasicSquareMapper;
 import com.gyee.backconfig.model.auto.ProBasicSquare;
 import com.gyee.backconfig.service.auto.IProBasicSquareService;
+import com.gyee.common.model.StringUtils;
 import org.springframework.stereotype.Service;
 
 /**
@@ -17,4 +21,37 @@ import org.springframework.stereotype.Service;
 @Service
 public class ProBasicSquareServiceImpl extends ServiceImpl<ProBasicSquareMapper, ProBasicSquare> implements IProBasicSquareService {
 
+    @Override
+    public IPage<ProBasicSquare> list(String id, String name, String aname, String nemCode, String windpowerstationId, String projectId, String lineId, String pageNum, String pageSize) {
+        QueryWrapper<ProBasicSquare> qw = new QueryWrapper<>();
+
+        if (StringUtils.isNotEmpty(id)){
+            qw.eq("id",id);
+        }
+
+        if (StringUtils.isNotEmpty(name)){
+            qw.like("name",name);
+        }
+
+        if (StringUtils.isNotEmpty(aname)){
+            qw.like("aname",aname);
+        }
+        if (StringUtils.isNotEmpty(nemCode)){
+            qw.eq("nem_code",nemCode);
+        }
+        if (StringUtils.isNotEmpty(windpowerstationId)){
+            qw.lambda().eq(ProBasicSquare::getWindpowerstationId,windpowerstationId);
+        }
+        if (StringUtils.isNotEmpty(projectId)){
+            qw.lambda().eq(ProBasicSquare::getProjectId,projectId);
+        }
+        if (StringUtils.isNotEmpty(lineId)){
+            qw.lambda().eq(ProBasicSquare::getLineId,lineId);
+        }
+
+
+        Page<ProBasicSquare> page = new Page<>(Integer.parseInt(pageNum),Integer.parseInt(pageSize));
+        IPage<ProBasicSquare> list = baseMapper.selectPage(page, qw);
+        return list;
+    }
 }