From e8b154e63e9db8750407c218eb13937f584bda8c Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期四, 15 五月 2025 11:12:37 +0800
Subject: [PATCH] 电池组管理

---
 src/main/java/com/whyc/service/BattInfService.java |  112 +++++++++++++++++++++++++-------------------------------
 1 files changed, 50 insertions(+), 62 deletions(-)

diff --git a/src/main/java/com/whyc/service/BattInfService.java b/src/main/java/com/whyc/service/BattInfService.java
index 269edb3..36fa164 100644
--- a/src/main/java/com/whyc/service/BattInfService.java
+++ b/src/main/java/com/whyc/service/BattInfService.java
@@ -4,6 +4,7 @@
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.whyc.dto.BattDto;
 import com.whyc.dto.PowerDto;
 import com.whyc.dto.Response;
 import com.whyc.mapper.BattInfMapper;
@@ -16,69 +17,50 @@
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Date;
 import java.util.List;
 
 @Service
 public class BattInfService {
     @Autowired(required = false)
     private BattInfMapper mapper;
-/*
+
 
     //娣诲姞鐢垫簮
     @Transactional
-    public Response addBatt(BattInf binf) {
-        //鍏堟牎楠屽綋鍓嶇敤鎴锋槸鍚﹀瓨鍦ㄥ寘鏈虹粍涓嶅瓨鍦ㄥ垯涓嶈娣诲姞鐢垫簮
-        User user= ActionUtil.getUser();
-        int flag=bjService.checkUserBaojiGroup(user.getId());
-        if(flag==0){
-            return new Response().set(1,false,"褰撳墠鐢ㄦ埛涓嶅瓨鍦ㄥ寘鏈虹粍");
-        }
-        //鏈烘埧淇℃伅
-        StationInf addsinf= addpinf.getSinf();
-        //鍒ゆ柇娣诲姞閿佺殑鏃跺�欐満鎴挎槸涓嶆槸鏂版満鎴�
-        String fullName=addsinf.getProvice()+"_"+addsinf.getCity()+"_"+addsinf.getCountry()+"_"+addsinf.getStationName();
-        //鍒ゆ柇鏈烘埧鏄惁瀛樺湪
+    public Response addBatt(BattInf addbinf) {
+        //鍒ゆ柇鐢垫睜缁勬槸鍚﹀瓨鍦�
         QueryWrapper wrapper=new QueryWrapper();
-        wrapper.eq("full_name",fullName);
+        wrapper.eq("station_id",addbinf.getStationId());
+        wrapper.eq("power_id",addbinf.getPowerId());
+        wrapper.eq("dev_name",addbinf.getDevName());
+        wrapper.eq("battgroup_name",addbinf.getBattgroupName());
         wrapper.last("limit 1");
-        StationInf sinf=sinfMapper.selectOne(wrapper);
-        int stationId=0;
-        int powerId=0;
-        if(sinf!=null){
-            stationId=sinf.getStationId();
+        BattInf binf=mapper.selectOne(wrapper);
+        int devId=0;
+        int battGroupId=0;
+        if(binf!=null){
+            return new Response().set(1,false,"褰撳墠鐢垫簮鏈烘埧涓嬪凡娣诲姞杩囪鐢垫睜缁�");
         }else {
-            //鑾峰彇瀵瑰簲鐨勬満鎴縤d
-            stationId = sinfMapper.getMaxStationId();
-            if (stationId == 0) {//鏁版嵁搴撲腑娌℃湁绔欑偣
-                stationId = 40000001;
+            //鑾峰彇瀵瑰簲鐨勮澶噄d,鐢垫睜缁�
+            devId = mapper.getMaxdevId();
+            battGroupId=mapper.getMaxBattGroupId();
+            if (devId == 0) {//鏁版嵁搴撲腑娌℃湁绔欑偣
+                devId = 10001;
             } else {
-                stationId += 1;
+                devId += 1;
             }
-            addsinf.setFullName(fullName);
-            addsinf.setStationId(stationId);
-            sinfMapper.insert(addsinf);
+            if (battGroupId == 0) {//鏁版嵁搴撲腑娌℃湁绔欑偣
+                battGroupId = 10001;
+            } else {
+                battGroupId += 1;
+            }
+            addbinf.setDevId(devId);
+            addbinf.setBattgroupId(battGroupId);
+            addbinf.setCreateTime(new Date());
+            mapper.insert(addbinf);
+            return new Response().set(1, true, "娣诲姞鐢垫睜缁�");
         }
-        //鍒ゆ柇鏈烘埧鏄惁瀛樺湪
-        QueryWrapper wrapper1=new QueryWrapper();
-        wrapper1.eq("power_name",addpinf.getPowerName());
-        wrapper1.eq("station_id",stationId);
-        wrapper1.last("limit 1");
-        PowerInf juegep=mapper.selectOne(wrapper);
-        if(juegep==null){
-            return new Response().set(1, false, "褰撳墠鏈烘埧涓嬪凡娣诲姞杩囪鐢垫簮");
-        }
-        //鍐嶆坊鍔犵數婧愪俊鎭�
-        addpinf.setStationId(stationId);
-        //鑾峰彇瀵瑰簲鐨勭數婧恑d
-        powerId = mapper.getMaxPowerId();
-        if (powerId == 0) {//鏁版嵁搴撲腑娌℃湁绔欑偣
-            powerId = 10001;
-        } else {
-            powerId += 1;
-        }
-        addpinf.setPowerId(powerId);
-        mapper.insert(addpinf);
-        return new Response().set(1, true, "娣诲姞鐢垫簮");
     }
     //鍒犻櫎鐢垫簮
     public Response delBatt(Integer bid) {
@@ -94,30 +76,36 @@
         if(binf.getBattgroupName()!=null){
             wrapper.set("battgroup_name",binf.getBattgroupName());
         }
-        if(binf.getCompany()!=null){
-            wrapper.set("company",pinf.getCompany());
+        if(binf.getMonvolstd()!=null){
+            wrapper.set("monvolstd",binf.getMonvolstd());
         }
-        if(pinf.getModel()!=null){
-            wrapper.set("model",pinf.getModel());
+        if(binf.getMoncapstd()!=null){
+            wrapper.set("moncapstd",binf.getMoncapstd());
         }
-        if(pinf.getProtocol()!=null){
-            wrapper.set("protocol",pinf.getProtocol());
+        if(binf.getMonresstd()!=null){
+            wrapper.set("monresstd",binf.getMonresstd());
         }
-        if(pinf.getPowerIp()!=null){
-            wrapper.set("power_ip",pinf.getPowerIp());
+        if(binf.getProduct()!=null){
+            wrapper.set("product",binf.getProduct());
         }
-        mapper.update((PowerInf) ActionUtil.objeNull,wrapper);
+        if(binf.getMoncount()!=null){
+            wrapper.set("moncount",binf.getMoncount());
+        }
+        if(binf.getModel()!=null){
+            wrapper.set("model",binf.getModel());
+        }
+        mapper.update((BattInf) ActionUtil.objeNull,wrapper);
         return new Response().set(1,true);
     }
-    //鏌ヨ鐢垫簮
-    public Response getBatt(PowerDto dto) {
+    //鏌ヨ鐢垫睜
+    public Response getBatt(BattDto dto) {
         User user= ActionUtil.getUser();
         dto.setUid(user.getId());
         PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
-        List<PowerInf> list=mapper.getPower(dto);
+        List<BattInf> list=mapper.getBatt(dto);
         PageInfo pageInfo=new PageInfo(list);
-        return new Response().setII(1,list!=null,pageInfo,"鏌ヨ鐢垫簮");
+        return new Response().setII(1,list!=null,pageInfo,"鏌ヨ鐢垫睜");
     }
-*/
+
 
 }
\ No newline at end of file

--
Gitblit v1.9.1