From c7e058bb6dc997bde478c488ddc98561c61085dc Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期六, 17 五月 2025 14:39:14 +0800
Subject: [PATCH] 查询机房,电源,电池组信息

---
 /dev/null                                                   |   44 --------
 src/main/java/com/whyc/service/BattInfService.java          |  131 ++++++++++++++++++++++++-
 src/main/java/com/whyc/controller/InfoContoller.java        |    7 
 src/main/java/com/whyc/service/PowerInfService.java         |   58 -----------
 src/main/java/com/whyc/factory/InfoFactory.java             |   24 ++++
 src/main/java/com/whyc/controller/StationInfController.java |   24 ----
 src/main/java/com/whyc/service/BaojigroupService.java       |    7 +
 7 files changed, 156 insertions(+), 139 deletions(-)

diff --git a/src/main/java/com/whyc/controller/BattInfController.java b/src/main/java/com/whyc/controller/BattInfController.java
deleted file mode 100644
index 45e05fd..0000000
--- a/src/main/java/com/whyc/controller/BattInfController.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.whyc.controller;
-
-import com.whyc.dto.BattDto;
-import com.whyc.dto.PowerDto;
-import com.whyc.dto.Response;
-import com.whyc.pojo.db_station.BattInf;
-import com.whyc.pojo.db_station.PowerInf;
-import com.whyc.service.BattInfService;
-import com.whyc.service.PowerInfService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-@RestController
-@Api(tags = "鐢垫睜缁勭鐞�")
-@RequestMapping("battInf")
-public class BattInfController {
-    @Autowired
-    private BattInfService service;
-
-
-    /*@ApiOperation(value = "璁惧娣诲姞鐢垫睜缁�")
-    @PostMapping("addBatt")
-    public Response addBatt(@RequestBody BattInf binf){
-        service.addBatt(binf);
-        return new Response().set(1,true);
-    }
-    @ApiOperation(value = "鏂板缓鐢垫睜缁勶紙鏂扮殑璁惧鏂扮殑鐢垫睜缁勶級")
-    @PostMapping("addDev")
-    public Response addDev(@RequestBody BattInf binf){
-         service.addDev(binf);
-        return new Response().set(1,true);
-    }
-
-    @ApiOperation(value = "鍒犻櫎鐢垫睜缁�")
-    @GetMapping("delBatt")
-    public Response delBatt(@RequestParam Integer bid){
-        return service.delBatt(bid);
-    }
-
-    @ApiOperation(value = "淇敼鐢垫睜缁�")
-    @PostMapping("updateBatt")
-    public Response updateBatt(@RequestBody BattInf binf){
-        return service.updateBatt(binf);
-    }*/
-
-   /* @ApiOperation(value = "鏌ヨ鐢垫睜缁�")
-    @PostMapping("getBatt")
-    public Response getBatt(@RequestBody BattDto dto){
-        return service.getBatt(dto);
-    }*/
-}
\ No newline at end of file
diff --git a/src/main/java/com/whyc/controller/InfoContoller.java b/src/main/java/com/whyc/controller/InfoContoller.java
index 16b7ce9..27c92d8 100644
--- a/src/main/java/com/whyc/controller/InfoContoller.java
+++ b/src/main/java/com/whyc/controller/InfoContoller.java
@@ -70,12 +70,11 @@
         return binfService.delBatt(stationId, powerId, battgroupId);
     }
 
-    /*@ApiOperation(value = "缂栬緫鏈烘埧锛岀數婧愶紝鐢垫睜缁勪俊鎭�")
+    @ApiOperation(value = "缂栬緫鏈烘埧锛岀數婧愶紝鐢垫睜缁勪俊鎭�")
     @PostMapping("updateInfo")
     public Response updateInfo(@RequestBody InfoDto info){
-        PowerInf pinf=InfoFactory.infoToPower(info);
-        BattInf binf=InfoFactory.infoToBatt(info);
-    }*/
+        return binfService.updateInfo(info);
+    }
 
     @ApiOperation(value = "鏌ヨ鏈烘埧锛岀數婧愶紝鐢垫睜缁勪俊鎭�")
     @PostMapping("getInfo")
diff --git a/src/main/java/com/whyc/controller/PowerInfController.java b/src/main/java/com/whyc/controller/PowerInfController.java
deleted file mode 100644
index 8305e2c..0000000
--- a/src/main/java/com/whyc/controller/PowerInfController.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.whyc.controller;
-
-import com.whyc.dto.PowerDto;
-import com.whyc.dto.Response;
-import com.whyc.pojo.db_station.PowerInf;
-import com.whyc.service.PowerInfService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-@RestController
-@Api(tags = "鐢垫簮绠$悊")
-@RequestMapping("powerInf")
-public class PowerInfController {
-    @Autowired
-    private PowerInfService service;
-
-/*
-    @ApiOperation(value = "娣诲姞鐢垫簮")
-    @PostMapping("addPower")
-    public Response addPower(@RequestBody PowerInf pinf){
-        service.addPower(pinf);
-        return new Response().set(1,true,"娣诲姞鎴愬姛");
-    }
-
-    @ApiOperation(value = "鍒犻櫎鐢垫簮")
-    @GetMapping("delPower")
-    public Response delPower(@RequestParam Integer pid){
-        return service.delPower(pid);
-    }
-
-    @ApiOperation(value = "淇敼鐢垫簮")
-    @PostMapping("updatePower")
-    public Response updatePower(@RequestBody PowerInf pinf){
-        return service.updatePower(pinf);
-    }
-
-    @ApiOperation(value = "鏌ヨ鐢垫簮")
-    @PostMapping("getPower")
-    public Response getPower(@RequestBody PowerDto dto){
-        return service.getPower(dto);
-    }*/
-}
\ No newline at end of file
diff --git a/src/main/java/com/whyc/controller/StationInfController.java b/src/main/java/com/whyc/controller/StationInfController.java
index 21dc3c1..1e15652 100644
--- a/src/main/java/com/whyc/controller/StationInfController.java
+++ b/src/main/java/com/whyc/controller/StationInfController.java
@@ -22,29 +22,5 @@
         User uinf= ActionUtil.getUser();
         return service.getLeftStation(uinf.getId());
     }
-/*
-    @ApiOperation(value = "娣诲姞鏈烘埧")
-    @PostMapping("addStatiaon")
-    public Response addStatiaon(@RequestBody StationInf sinf){
-        return service.addStatiaon(sinf);
-    }
-
-    @ApiOperation(value = "鍒犻櫎鏈烘埧")
-    @GetMapping("delStatiaon")
-    public Response delStatiaon(@RequestParam Integer stationId){
-        return service.delStatiaon(stationId);
-    }
-
-    @ApiOperation(value = "淇敼鏈烘埧")
-    @PostMapping("updateStatiaon")
-    public Response updateStatiaon(@RequestBody StationInf sinf){
-        return service.updateStatiaon(sinf);
-    }
-
-    @ApiOperation(value = "鏌ヨ鏈烘埧")
-    @PostMapping("getStatiaon")
-    public Response getStatiaon(@RequestBody StationDto dto){
-        return service.getStatiaon(dto);
-    }*/
 
 }
\ No newline at end of file
diff --git a/src/main/java/com/whyc/factory/InfoFactory.java b/src/main/java/com/whyc/factory/InfoFactory.java
index 8bec477..0f9e46e 100644
--- a/src/main/java/com/whyc/factory/InfoFactory.java
+++ b/src/main/java/com/whyc/factory/InfoFactory.java
@@ -13,6 +13,24 @@
                 .setPowerModel(info.getPowerModel())
                 .setProtocol(info.getProtocol())
                 .setPowerIp(info.getPowerIp());
+        if(info.getProvice()!=null){
+            pinf.setProvice(info.getProvice());
+        }
+        if(info.getCity()!=null){
+            pinf.setCity(info.getCity());
+        }
+        if(info.getCountry()!=null){
+            pinf.setCountry(info.getCountry());
+        }
+        if(info.getStationName()!=null){
+            pinf.setStationName(info.getStationName());
+        }
+        if(info.getStationId()!=null){
+            pinf.setStationId(info.getStationId());
+        }
+        if(info.getPowerId()!=null){
+            pinf.setPowerId(info.getPowerId());
+        }
         StationInf sinf=new StationInf();
         sinf.setProvice(info.getProvice())
                 .setCity(info.getCity())
@@ -35,6 +53,12 @@
                 .setMonvolstd(info.getMonvolstd())
                 .setProduct(info.getProduct())
                 .setBattModel(info.getBattModel());
+        if(info.getBattgroupId()!=null){
+            binf.setBattgroupId(info.getBattgroupId());
+        }
+        if(info.getDevId()!=null){
+            binf.setDevId(info.getDevId());
+        }
         return binf;
     }
 }
\ No newline at end of file
diff --git a/src/main/java/com/whyc/service/BaojigroupService.java b/src/main/java/com/whyc/service/BaojigroupService.java
index 5145e9a..2a3f9e3 100644
--- a/src/main/java/com/whyc/service/BaojigroupService.java
+++ b/src/main/java/com/whyc/service/BaojigroupService.java
@@ -237,4 +237,11 @@
         update.eq("power_id",pid);
         bjPowermapper.delete(update);
     }
+
+    //鍒犻櫎鍖呮満缁勪笅鐨勬満鎴�
+    public void delStationInBaoji(Integer sid) {
+        UpdateWrapper<BaojigroupPower> update = Wrappers.update();
+        update.eq("station_id",sid);
+        bjPowermapper.delete(update);
+    }
 }
\ No newline at end of file
diff --git a/src/main/java/com/whyc/service/BattInfService.java b/src/main/java/com/whyc/service/BattInfService.java
index a4c0bd1..f502949 100644
--- a/src/main/java/com/whyc/service/BattInfService.java
+++ b/src/main/java/com/whyc/service/BattInfService.java
@@ -6,8 +6,8 @@
 import com.github.pagehelper.PageInfo;
 import com.whyc.dto.BattDto;
 import com.whyc.dto.InfoDto;
-import com.whyc.dto.PowerDto;
 import com.whyc.dto.Response;
+import com.whyc.factory.InfoFactory;
 import com.whyc.mapper.BattInfMapper;
 import com.whyc.mapper.PowerInfMapper;
 import com.whyc.mapper.StationInfMapper;
@@ -33,6 +33,9 @@
 
     @Autowired(required = false)
     private StationInfMapper sinfMapper;
+
+    @Autowired(required = false)
+    private BaojigroupService bjService;
 
     /*鏂板缓鐢垫睜缁勶紙鏂扮殑璁惧鏂扮殑鐢垫睜缁勶級
      * @param binf
@@ -118,6 +121,8 @@
             UpdateWrapper wrapper2=new UpdateWrapper();
             wrapper2.eq("power_id",powerId);
             pinfMapper.delete(wrapper);
+            //鍒犻櫎鎵�鏈夊寘鏈虹粍涓嬬殑鐢垫簮
+            bjService.delPowerInBaoji(powerId);
             //鍐嶆娴嬪鏋滄満鎴夸笅鐢垫簮涔熷叏鍒犻櫎浜嗭紝瑕佸皢鏈烘埧涔熷垹闄�
             QueryWrapper wrapper3=new QueryWrapper();
             wrapper3.eq("station_id",stationId);
@@ -126,11 +131,124 @@
                 UpdateWrapper wrapper4=new UpdateWrapper();
                 wrapper4.eq("station_id",stationId);
                 sinfMapper.delete(wrapper4);
+                //鍒犻櫎鎵�鏈夊寘鏈虹粍涓嬬殑鏈烘埧
+                bjService.delStationInBaoji(stationId);
             }
         }
         return new Response().set(1,true);
     }
-    //淇敼鐢垫睜缁�
+    //缂栬緫鏈烘埧锛岀數婧愶紝鐢垫睜缁勪俊鎭�
+    @Transactional
+    public Response updateInfo(InfoDto info) {
+        //鍏堜慨鏀规満鎴夸俊鎭�
+        PowerInf pinf=InfoFactory.infoToPower(info);
+        StationInf sinf=pinf.getSinf();
+        UpdateWrapper wrapper1=new UpdateWrapper();
+        if(sinf.getStationName()!=null){
+            wrapper1.set("station_name",sinf.getStationName());
+            String fullName=sinf.getProvice()+"_"+sinf.getCity()+"_"+sinf.getCountry()+"_"+sinf.getStationName();
+            wrapper1.set("full_name",fullName);
+        }
+        if(sinf.getStationType()!=null){
+            wrapper1.set("station_type",sinf.getStationType());
+        }
+        if(sinf.getLongitude()!=null){
+            wrapper1.set("longitude",sinf.getLongitude());
+        }
+        if(sinf.getLatitude()!=null){
+            wrapper1.set("latitude",sinf.getLatitude());
+        }
+        wrapper1.eq("station_id",sinf.getStationId());
+        sinfMapper.update((StationInf) ActionUtil.objeNull,wrapper1);
+        //鍐嶄慨鏀圭數婧愪俊鎭�
+        UpdateWrapper wrapper2=new UpdateWrapper();
+        if(pinf.getCompany()!=null){
+            wrapper2.set("company",pinf.getCompany());
+        }
+        if(pinf.getPowerModel()!=null){
+            wrapper2.set("power_model",pinf.getPowerModel());
+        }
+        if(pinf.getProtocol()!=null){
+            wrapper2.set("protocol",pinf.getProtocol());
+        }
+        if(pinf.getPowerIp()!=null){
+            wrapper2.set("power_ip",pinf.getPowerIp());
+        }
+        if(pinf.getPowerName()!=null){
+            //妫�娴嬭鏈烘埧涓嬭淇敼鐨勭數婧愬悕鏄惁瀛樺湪
+            QueryWrapper queryWrapper=new QueryWrapper();
+            queryWrapper.eq("power_name",pinf.getPowerName());
+            queryWrapper.eq("station_id",pinf.getStationId());
+            queryWrapper.last("limit 1");
+            PowerInf juegep=pinfMapper.selectOne(queryWrapper);
+            if(juegep!=null){
+                return new Response().set(1,false,"璇ユ満鎴夸笅宸插瓨鍦�"+pinf.getPowerName()+"鐨勭數婧�");
+            }
+            wrapper2.set("power_name",pinf.getPowerName());
+        }
+        wrapper2.eq("power_id",pinf.getPowerId());
+        pinfMapper.update((PowerInf) ActionUtil.objeNull,wrapper2);
+        //鏈�鍚庝慨鏀硅澶囦俊鎭�
+        BattInf binf=InfoFactory.infoToBatt(info);
+        UpdateWrapper wrapper3=new UpdateWrapper();
+        if(binf.getDevIp()!=null){
+            wrapper3.set("dev_ip",binf.getDevIp());
+        }
+        if(binf.getDevName()!=null){
+            //妫�娴嬭鐢垫簮涓嬩慨鏀圭殑璁惧鍚嶆槸鍚﹀瓨鍦�
+            QueryWrapper queryWrapper1=new QueryWrapper();
+            queryWrapper1.eq("dev_name",binf.getDevName());
+            queryWrapper1.eq("power_id",pinf.getPowerId());
+            queryWrapper1.last("limit 1");
+            BattInf jueged=mapper.selectOne(queryWrapper1);
+            if(jueged!=null){
+                return new Response().set(1,false,"璇ョ數婧愪笅宸插瓨鍦�"+binf.getDevName()+"鐨勮澶�");
+            }
+            wrapper3.set("dev_name",binf.getDevName());
+        }
+        if(binf.getDevType()!=null){
+            wrapper3.set("dev_type",binf.getDevType());
+        }
+        wrapper3.eq("dev_id",binf.getDevId());
+        mapper.update((BattInf) ActionUtil.objeNull,wrapper3);
+
+        //淇敼鐢垫睜缁勪俊鎭�
+        UpdateWrapper wrapper4=new UpdateWrapper();
+        if(binf.getBattgroupName()!=null){
+            //妫�娴嬭鏈烘埧涓嬭淇敼鐨勭數婧愬悕鏄惁绮楀湪
+            QueryWrapper queryWrapper=new QueryWrapper();
+            queryWrapper.eq("battgroup_name",binf.getBattgroupName());
+            queryWrapper.eq("dev_id",binf.getDevId());
+            queryWrapper.last("limit 1");
+            BattInf juegeb=mapper.selectOne(queryWrapper);
+            if(juegeb!=null){
+                return new Response().set(1,false,"璇ヨ澶囦笅宸插瓨鍦�"+binf.getBattgroupName()+"鐨勭數姹犵粍");
+            }
+            wrapper4.set("battgroup_name",binf.getBattgroupName());
+        }
+        if(binf.getMonvolstd()!=null){
+            wrapper4.set("monvolstd",binf.getMonvolstd());
+        }
+        if(binf.getMoncapstd()!=null){
+            wrapper4.set("moncapstd",binf.getMoncapstd());
+        }
+        if(binf.getMonresstd()!=null){
+            wrapper4.set("monresstd",binf.getMonresstd());
+        }
+        if(binf.getProduct()!=null){
+            wrapper4.set("product",binf.getProduct());
+        }
+        if(binf.getMoncount()!=null){
+            wrapper4.set("moncount",binf.getMoncount());
+        }
+        if(binf.getBattModel()!=null){
+            wrapper4.set("batt_model",binf.getBattModel());
+        }
+        wrapper4.eq("battgroup_id",binf.getBattgroupId());
+        mapper.update((BattInf) ActionUtil.objeNull,wrapper4);
+        return new Response().set(1,true);
+    }
+    /*//淇敼鐢垫睜缁�
     public Response updateBatt(BattInf binf) {
         UpdateWrapper wrapper1=new UpdateWrapper();
         wrapper1.eq("dev_id",binf.getDevId());
@@ -174,7 +292,7 @@
         }
         mapper.update((BattInf) ActionUtil.objeNull,wrapper);
         return new Response().set(1,true);
-    }
+    }*/
     //鏌ヨ鏈烘埧锛岀數婧愶紝鐢垫睜缁勪俊鎭�
     public Response getInfo(BattDto dto) {
         User user= ActionUtil.getUser();
@@ -183,12 +301,6 @@
         List<InfoDto> list=mapper.getInfo(dto);
         PageInfo pageInfo=new PageInfo(list);
         return new Response().setII(1,list!=null,pageInfo,"鏌ヨ鐢垫睜");
-    }
-    //鍒犻櫎鐢垫簮涓嬬殑鐢垫睜缁�
-    public void delBattInPower(Integer pid) {
-        UpdateWrapper wrapper=new UpdateWrapper();
-        wrapper.eq("power_id",pid);
-        mapper.delete(wrapper);
     }
 
     //鑾峰彇鐢垫睜鍝佺墝(涓嬫媺)
@@ -218,4 +330,5 @@
         List<String> list=mapper.getDevTypeByUid(uid);
         return new Response().setII(1,list.size()>0,list,"鑾峰彇璁惧鍨嬪彿(涓嬫媺)");
     }
+
 }
\ No newline at end of file
diff --git a/src/main/java/com/whyc/service/PowerInfService.java b/src/main/java/com/whyc/service/PowerInfService.java
index 7fd1a9c..2a8827d 100644
--- a/src/main/java/com/whyc/service/PowerInfService.java
+++ b/src/main/java/com/whyc/service/PowerInfService.java
@@ -27,11 +27,6 @@
     @Autowired(required = false)
     private StationInfMapper sinfMapper;
 
-    @Autowired(required = false)
-    private BaojigroupService bjService;
-
-    @Autowired(required = false)
-    private BattInfService binfService;
 
     /*娣诲姞鐢垫簮
     1.鍒ゆ柇褰撳墠鐢ㄦ埛鏄惁鏄寘缁勭敤鎴�
@@ -85,59 +80,6 @@
         }
         addpinf.setPowerId(powerId);
         mapper.insert(addpinf);
-    }
-    //鍒犻櫎鐢垫簮锛堝垹闄ゅ寘鏈虹粍涓嬭褰曪紝鍒犻櫎鐢垫簮涓嬬殑鐢垫睜缁勮澶囷級
-    @Transactional
-    public Response delPower(Integer pid) {
-        //鍒犻櫎鎵�鏈夊寘鏈虹粍涓嬬殑鐢垫簮
-        bjService.delPowerInBaoji(pid);
-        //鍒犻櫎鐢垫簮涓嬬殑鐢垫睜缁�
-        binfService.delBattInPower(pid);
-        //鍒犻櫎鐢垫簮
-        UpdateWrapper wrapper=new UpdateWrapper();
-        wrapper.eq("power_id",pid);
-        mapper.delete(wrapper);
-        return new Response().set(1,true);
-    }
-    //淇敼鐢垫簮
-    public Response updatePower(PowerInf pinf) {
-        UpdateWrapper wrapper=new UpdateWrapper();
-        wrapper.eq("power_id",pinf.getPowerId());
-        if(pinf.getPowerName()!=null){
-            //妫�娴嬭鏈烘埧涓嬭淇敼鐨勭數婧愬悕鏄惁绮楀湪
-            QueryWrapper queryWrapper=new QueryWrapper();
-            queryWrapper.eq("power_name",pinf.getPowerName());
-            queryWrapper.eq("station_id",pinf.getStationId());
-            queryWrapper.last("limit 1");
-            PowerInf juegep=mapper.selectOne(queryWrapper);
-            if(juegep!=null){
-                return new Response().set(1,false,"璇ユ満鎴夸笅宸插瓨鍦�"+pinf.getPowerName()+"鐨勭數婧�");
-            }
-            wrapper.set("power_name",pinf.getPowerName());
-        }
-        if(pinf.getCompany()!=null){
-            wrapper.set("company",pinf.getCompany());
-        }
-        if(pinf.getPowerModel()!=null){
-            wrapper.set("power_model",pinf.getPowerModel());
-        }
-        if(pinf.getProtocol()!=null){
-            wrapper.set("protocol",pinf.getProtocol());
-        }
-        if(pinf.getPowerIp()!=null){
-            wrapper.set("power_ip",pinf.getPowerIp());
-        }
-        mapper.update((PowerInf) ActionUtil.objeNull,wrapper);
-        return new Response().set(1,true);
-    }
-    //鏌ヨ鐢垫簮
-    public Response getPower(PowerDto dto) {
-        User user= ActionUtil.getUser();
-        dto.setUid(user.getId());
-        PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
-        List<PowerInf> list=mapper.getPower(dto);
-        PageInfo pageInfo=new PageInfo(list);
-        return new Response().setII(1,list!=null,pageInfo,"鏌ヨ鐢垫簮");
     }
     //鑾峰彇鐢垫簮鍝佺墝(涓嬫媺)
     public Response getCompanyByUid(Integer uid) {

--
Gitblit v1.9.1