From e16302f9d475c7cc4dd18c5abf1a23cb5502e362 Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期三, 28 五月 2025 14:57:56 +0800
Subject: [PATCH] 密码验证加-

---
 src/main/java/com/whyc/controller/PowerInfController.java |  191 +++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 164 insertions(+), 27 deletions(-)

diff --git a/src/main/java/com/whyc/controller/PowerInfController.java b/src/main/java/com/whyc/controller/PowerInfController.java
index 8205007..c69744e 100644
--- a/src/main/java/com/whyc/controller/PowerInfController.java
+++ b/src/main/java/com/whyc/controller/PowerInfController.java
@@ -1,77 +1,142 @@
 package com.whyc.controller;
 
-import com.github.pagehelper.PageInfo;
 import com.whyc.dto.Response;
+import com.whyc.dto.paramter.PowerInfPar;
+import com.whyc.factory.BattinfGroupFactory;
+import com.whyc.pojo.Battinf;
 import com.whyc.pojo.PowerInf;
+import com.whyc.pojo.StationInf;
 import com.whyc.pojo.UserInf;
+import com.whyc.service.BattInfService;
+import com.whyc.service.PowerAppSysService;
 import com.whyc.service.PowerInfService;
+import com.whyc.service.StationInfService;
 import com.whyc.util.ActionUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
 @RequestMapping("powerInf")
 @RestController
-@Api(tags = "鐢垫簮绠$悊")
-public class PowerInfController {
+@Api(tags = "鏁版嵁绠$悊-鐢垫簮淇℃伅")
+public class PowerInfController extends BaseController{
     @Autowired
     private PowerInfService service;
+    @Autowired
+    private BattInfService battInfService;
+    @Autowired
+    private PowerAppSysService powerAppSysService;
+    @Autowired
+    private StationInfService stationInfService;
 
     @PostMapping
     @ApiOperation(value = "娣诲姞鐢垫簮")
+    @Transactional
     public Response add(@RequestBody PowerInf powerInf){
-        service.add(powerInf);
-        return new Response().setII(1,"娣诲姞鎴愬姛");
+        int userId = ((UserInf)ActionUtil.getSession().getAttribute("user")).getUId().intValue();
+        Response res = new Response();
+        if(StringUtils.isEmpty(powerInf.getStationId())){
+            //鏍¢獙鏈烘埧绔欑偣鏄惁瀛樺湪,瀛樺湪鍒欎笉闇�瑕佹柊寤篠tationId
+            Battinf battinf = battInfService.judgeBattStationName3(powerInf);
+            if (battinf!=null) {
+                powerInf.setStationId(battinf.getStationId());
+            }else {
+                //绔欑偣涓嶅瓨鍦�,闇�瑕佹柊寤虹珯鐐硅褰�
+                String nextStationId = battInfService.getNextStationId();
+                StationInf station = new StationInf();
+                station.setStationId(nextStationId);
+                station.setStationName(powerInf.getStationName());
+                station.setStationName1(powerInf.getStationName1());
+                station.setStationName2(powerInf.getStationName2());
+                station.setStationName3(powerInf.getStationName3());
+                station.setStationName5(powerInf.getStationName5());
+                stationInfService.insertStation(station);
+                //powerInf.setStationId(String.valueOf(battInfService.searchMaxId_zj()));
+                powerInf.setStationId(nextStationId);
+            }
+        }
+        int devId = battInfService.getPowerDeviceId(powerInf.getPowerDeviceType());
+        powerInf.setPowerDeviceId(devId);
+        if (service.add(powerInf)>0){
+            //娣诲姞鏈烘埧绔欑偣鍒扮敤鎴峰搴旂殑鍖呮満缁�
+            battInfService.insertUserBattgroupBaojigroupBattgroupSelect(powerInf.getStationId(),0,userId);
+            //娣诲姞鐢垫簮绔欑偣鏃�,鏇存柊ReInit瀛楁涓�1,閫氳绋嬪簭鐩戞帶鍙樺寲閲嶆柊鍒濆鍖�
+            if(powerInf.getPowerDeviceType()==BattinfGroupFactory.DEVICE_POWER) {
+                boolean flag = powerAppSysService.updateFlag("AppServer_Reinit_PowerData_EN");
+                if (!flag) {
+                    System.out.println("鏇存柊updateReInit鎺ュ彛澶辫触");
+                }
+            }else{
+                //鍏呯數鏈哄拰缁濈紭瑁呯疆鐨�,鏇存柊鍙︿竴涓猂eInit瀛楁涓�1
+                boolean flag = powerAppSysService.updateFlag("AppServer_Reinit_BattGroupData_EN");
+                if (!flag) {
+                    System.out.println("鏇存柊updateReInit鎺ュ彛澶辫触");
+                }
+            }
+            res.set(1,true,"娣诲姞鎴愬姛");
+        }else{
+            res.set(1,false,"娣诲姞澶辫触");
+        }
+
+        return res;
     }
-    @PutMapping
+    @PostMapping("update")
     @ApiOperation(value = "鏇存柊鐢垫簮")
     public Response update(@RequestBody PowerInf powerInf){
         service.updateByPowerDeviceId(powerInf);
-        return new Response().setII(1,"鏇存柊鎴愬姛");
+        return new Response().set(1,true,"鏇存柊鎴愬姛");
     }
-    @DeleteMapping
+    @PostMapping("delete")
     @ApiOperation(value = "鍒犻櫎鐢垫簮")
     public Response delete(@RequestParam Integer powerDeviceId){
         service.deleteByPowerDeviceId(powerDeviceId);
-        return new Response().setII(1,"鍒犻櫎鎴愬姛");
+        return new Response().set(1,true,"鍒犻櫎鎴愬姛");
+    }
+
+    @GetMapping("updateSwtichNum")
+    @ApiOperation(value = "鏇存柊寮�鍏宠矾鏁�")
+    public Response updateSwtichNum(@RequestParam int swtichNum,@RequestParam int powerId){
+        service.updateSwtichNum(swtichNum,powerId);
+        return new Response().set(1,true,"鏇存柊鎴愬姛");
     }
 
 
-
-    @GetMapping("/getProvincesContainBatt")
-    @ApiOperation(value = "鑾峰彇鍖呭惈鐢垫睜鐨勭渷浠�")
+    @GetMapping("getProvincesContainBatt")
+    @ApiOperation(value = "鑾峰彇鎵�鏈夌渷浠�")
     public Response getProvincesContainBatt(){
         return service.getProvincesContainBatt();
     }
 
-    @GetMapping("/getCitiesContainBatt")
-    @ApiOperation(value = "鑾峰彇鏌愮渷涓嬬殑鍩庡競")
+    @GetMapping("getCitiesContainBatt")
+    @ApiOperation(value = "鑾峰彇鎵�鏈夊煄甯�")
     public Response getCitiesContainBatt(@RequestParam String stationName1){
         return service.getCitiesContainBatt(stationName1);
     }
 
-    @GetMapping("/getDistrictsContainBatt")
-    @ApiOperation(value = "鑾峰彇鏌愮渷鏌愬煄甯備笅鐨勫湴鍖�")
+    @GetMapping("getDistrictsContainBatt")
+    @ApiOperation(value = "鑾峰彇鎵�鏈夊湴鍖�")
     public Response getDistrictsContainBatt(@RequestParam String stationName1,@RequestParam String stationName2){
         return service.getDistrictsContainBatt(stationName1,stationName2);
     }
 
-    @GetMapping("/getProvinces")
+    @GetMapping("getProvinces")
     @ApiOperation(value = "鐢ㄦ埛绠$悊鐨勬満鎴跨渷浠�")
     public Response getProvinces(){
         UserInf userInf = (UserInf) ActionUtil.getUser();
         return service.getProvinces(userInf.getUId());
     }
-    @GetMapping("/getCities")
+    @GetMapping("getCities")
     @ApiOperation(value = "鐢ㄦ埛绠$悊鐨勭渷浠界殑鍩庡競")
     public Response getCities(@RequestParam(required = false) String stationName1){
         UserInf userInf = (UserInf) ActionUtil.getUser();
         return service.getCities(userInf.getUId(),stationName1);
     }
-    @GetMapping("/getDistricts")
+    @GetMapping("getDistricts")
     @ApiOperation(value = "鐢ㄦ埛绠$悊鐨勫湴鍖�")
     public Response getDistricts(@RequestParam(required = false) String stationName1,@RequestParam(required = false) String stationName2){
         UserInf userInf = (UserInf) ActionUtil.getUser();
@@ -79,17 +144,89 @@
     }
 
 
-    @GetMapping("/getExistStations")
-    @ApiOperation(value = "鑾峰彇鏈烘埧")
-    public Response getExistStations( @RequestParam String stationName1,@RequestParam String stationName2,@RequestParam String stationName5){
+    @GetMapping("getExistStations")
+    @ApiOperation(value = "鑾峰彇鎵�鏈夋満鎴�")
+    public Response getExistStations( @RequestParam(required = false) String stationName1,@RequestParam(required = false) String stationName2,@RequestParam(required = false) String stationName5){
         return service.getExistStations(stationName1,stationName2,stationName5);
     }
 
-    @GetMapping("/getPowerDevicesPage")
-    @ApiOperation(value = "鐢ㄦ埛绠$悊鐨勭數婧愪俊鎭垎椤�")
-    public PageInfo<PowerInf> getPowerDevicesPage(@RequestParam(required = false) String stationId, @RequestParam(required = false) String stationName1,@RequestParam(required = false) String stationName2,@RequestParam(required = false) String stationName5){
+    @GetMapping("getStations")
+    @ApiOperation(value = "鑾峰彇鐢ㄦ埛绠$悊鐨勬満鎴�")
+    public Response getStations(@RequestParam(required = false) String stationName5){
         UserInf userInf = (UserInf) ActionUtil.getUser();
-        PageInfo<PowerInf> list = service.getPowerDevicesPage(userInf.getUId(),stationId, stationName1,stationName2,stationName5);
-        return list;
+        return service.getStations(userInf.getUId(),stationName5);
     }
+
+    @PostMapping("getPowerDevicesPage")
+    @ApiOperation(value = "鐢ㄦ埛绠$悊鐨勭數婧愪俊鎭垎椤�")
+    public Response getPowerDevicesPage(@RequestParam int pageNum, @RequestParam int pageSize
+            , @RequestBody PowerInfPar powerInfPar) {
+        UserInf userInf = (UserInf) ActionUtil.getUser();
+        return service.getPowerDevicesPage(pageNum, pageSize, userInf.getUId(), powerInfPar);
+    }
+
+
+    @GetMapping("getPowerDevices")
+    @ApiOperation(value = "鐢ㄦ埛绠$悊鐨勭數婧愪俊鎭�")
+    public Response getPowerDevices(@RequestParam String stationId){
+        UserInf userInf = (UserInf) ActionUtil.getUser();
+        return service.getPowerDevices(stationId);
+    }
+
+    @GetMapping("getInfoById")
+    @ApiOperation(tags = "鍦ㄧ嚎鐩戞祴-瀹炴椂鐩戞帶",value = "鍦ㄧ嚎鐩戞祴-瀹炴椂鐩戞帶-鏌ヨ鏌愪釜鐢垫簮鐨勮缁嗕俊鎭�")
+    public Response getInfoById(@RequestParam int powerDeviceId){
+        return service.getInfoById(powerDeviceId);
+    }
+
+    /*@GetMapping("getPowerInfoById")
+    @ApiOperation(tags = "鍦ㄧ嚎鐩戞祴-瀹炴椂鐩戞帶",value = "鍦ㄧ嚎鐩戞祴-瀹炴椂鐩戞帶-鑾峰彇閰嶇數鏌滅殑瀹炴椂鏁版嵁")
+    public Response getPowerInfoById(@RequestParam int powerDeviceId){
+        return service.getPowerInfoById(powerDeviceId);
+    }*/
+
+    @ApiOperation(value = "濉啓寮傚父鍘熷洜",notes = "浼犲叆瀛楁 num,exceptionCause,exceptionCauseAnalysis")
+    @PostMapping("exceptionCause")
+    public Response updateExceptionCause(@RequestBody PowerInf powerInf){
+        return service.updateExceptionCause(powerInf);
+    }
+
+    @ApiOperation(value = "鍙栨秷寮傚父鍘熷洜", notes = "浼犲叆瀛楁 num")
+    @PostMapping("cancelExceptionCause")
+    public Response updateCancelExceptionCause(@RequestParam int num) {
+        return service.updateCancelExceptionCause(num);
+    }
+
+    @ApiOperation(value = "鏌ヨ寮傚父鍘熷洜", notes = "浼犲叆瀛楁 num")
+    @GetMapping("exceptionCause")
+    public Response getExceptionCause(@RequestParam int num) {
+        return service.getExceptionCause(num);
+    }
+
+
+    @GetMapping("getPwrInf")
+    @ApiOperation(value = "鑾峰彇鐢ㄦ埛绠$悊鐨勬満鎴�")
+    public Response getPwrInf() {
+        UserInf userInf = (UserInf) ActionUtil.getUser();
+        return service.getPwrInf(userInf.getUId());
+    }
+
+    @GetMapping("getPwrProducer")
+    @ApiOperation(value = "鑾峰彇鎵�鏈夌殑鐢垫簮鍝佺墝")
+    public Response getPwrProducer() {
+        return service.getPwrProducer();
+    }
+
+    @GetMapping("modelList")
+    @ApiOperation(value = "鑾峰彇鎵�鏈夌殑鍨嬪彿")
+    public Response getModelList() {
+        return service.getModelList();
+    }
+
+    @PostMapping("getModelListByPwrProducer")
+    @ApiOperation(value = "鏍规嵁鍝佺墝鏌ヨ鍨嬪彿")
+    public Response getModelListByPwrProducer(@RequestBody List<String> producer) {
+        return service.getModelListByPwrProducer(producer);
+    }
+
 }

--
Gitblit v1.9.1