From d2b83e3617bfc819b2ceb4658b24124e6146bfa3 Mon Sep 17 00:00:00 2001
From: wuzeyu <1223318623@qq.com>
Date: 星期六, 21 十二月 2024 11:01:59 +0800
Subject: [PATCH] 优化接口 删除流浪控制器,没有删除内容也显示成功 rtu增加 梅江备份config.xml文件

---
 pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/IntakeControllerCtrl.java |   82 ++++++++++++++++++++++++++++-------------
 1 files changed, 56 insertions(+), 26 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/IntakeControllerCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/IntakeControllerCtrl.java
index 252376c..aa2977a 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/IntakeControllerCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/IntakeControllerCtrl.java
@@ -1,7 +1,6 @@
 package com.dy.pipIrrProject.intakeController;
 
 
-import cn.hutool.core.date.DateTime;
 import com.dy.common.aop.SsoAop;
 import com.dy.common.webUtil.BaseResponse;
 import com.dy.common.webUtil.BaseResponseUtils;
@@ -103,7 +102,9 @@
         prController.setIntakeId(intakeId);
         prController.setRtuAddr(prControllerTramp.getRtuAddr());
         prController.setProtocol(prControllerTramp.getProtocol());
+        prController.setProtocolVersion(prControllerTramp.getProtocolVersion());
         prController.setFindDt(prControllerTramp.getFindDt());
+        prController.setOrgTag(prControllerTramp.getOrgTag());
         prController.setAddWays((byte) 1);
         prController.setOperator(operator);
         Date operateTime = new Date();
@@ -113,17 +114,18 @@
         if (rec_addController == 0) {
             return BaseResponseUtils.buildFail(ProjectResultCode.BIND_FAIL.getMessage());
         }
+//        if (remarks != null || remarks !=""){
+//            // 淇敼缁戝畾璁板綍
+//            PrIntakeController prIntakeController = new PrIntakeController();
+//            prIntakeController.setRemarks(remarks);
+//            prIntakeController.setIntakeid(intakeId);
+//
+//            Integer rec = Optional.ofNullable(intakeControllerSv.updateBindRecord(prIntakeController)).orElse(0);
+//            if (rec == 0) {
+//                return BaseResponseUtils.buildFail(ProjectResultCode.BIND_FAIL.getMessage());
+//            }
+//        }
 
-
-        // 淇敼缁戝畾璁板綍
-        PrIntakeController prIntakeController = new PrIntakeController();
-        prIntakeController.setRemarks(remarks);
-        prIntakeController.setIntakeid(intakeId);
-
-        Integer rec = Optional.ofNullable(intakeControllerSv.updateBindRecord(prIntakeController)).orElse(0);
-        if (rec == 0) {
-            return BaseResponseUtils.buildFail(ProjectResultCode.BIND_FAIL.getMessage());
-        }
 
         // 鏍规嵁娴佹氮鎺у埗鍣ㄧ紪鍙峰垹闄ゆ祦娴帶鍒跺櫒璁板綍
         intakeControllerSv.deleteTrampController(trampControllerId);
@@ -176,13 +178,24 @@
         Date operateTime = new Date();
         prIntakeController.setOperatedt(operateTime);
         prIntakeController.setOperatetype((byte) 2);
+        prIntakeController.setRemarks("瑙g粦");
         Integer rec = Optional.ofNullable(intakeControllerSv.addRecord(prIntakeController)).orElse(0);
         if (rec == 0) {
             return BaseResponseUtils.buildFail(ProjectResultCode.BIND_FAIL.getMessage());
         }
-
-        // 鍒犻櫎鎺у埗鍣ㄥ閿�
-        Integer rec_deleteIntakeId = Optional.ofNullable(controllerSv.deleteIntakeId(po.getControllerId())).orElse(0);
+        //娣诲姞鍒版祦娴帶鍒跺櫒
+        PrController ControllerList = controllerSv.getByControllerId(po.getControllerId());
+        PrControllerTramp prControllerTramp = new PrControllerTramp();
+        prControllerTramp.setRtuAddr(ControllerList.getRtuAddr());
+        prControllerTramp.setProtocol(ControllerList.getProtocol());
+        prControllerTramp.setFindDt(new Date());
+        prControllerTramp.setOrgTag(ControllerList.getOrgTag());
+        Integer rec_addControllerTramp = Optional.ofNullable(intakeControllerSv.addTrampController(prControllerTramp)).orElse(0);
+        if (rec_addControllerTramp == 0) {
+            return BaseResponseUtils.buildFail(ProjectResultCode.ADD_TRAMP_CONTROLLER_FAIL.getMessage());
+        }
+        // 鍒犻櫎鎺у埗鍣�
+        Integer rec_deleteIntakeId = Optional.ofNullable(controllerSv.deleteControllerByIdTwo(po.getControllerId())).orElse(0);
         if (rec_deleteIntakeId == 0) {
             return BaseResponseUtils.buildFail(ProjectResultCode.BIND_FAIL.getMessage());
         }
@@ -271,16 +284,15 @@
     @GetMapping(path = "/getTrampControllers")
     @SsoAop()
     public BaseResponse<QueryResultVo<List<PrControllerTramp>>> getTrampControllers(TrampControllerQueryVo vo) {
-
         try {
-            QueryResultVo<List<PrControllerTramp>> res = intakeControllerSv.getTrampControllers(vo);
-            if (res.itemTotal != null && res.itemTotal > 0) {
-                return BaseResponseUtils.buildSuccess(res);
-            } else {
-                //璇锋眰鎴愬姛浣嗘暟鎹负绌�
-                return BaseResponseUtils.buildSuccess(res);
-            }
-            //return BaseResponseUtils.buildSuccess(res);
+            //QueryResultVo<List<PrControllerTramp>> res = intakeControllerSv.getTrampControllers(vo);
+            //if (res.itemTotal != null && res.itemTotal > 0) {
+            //    return BaseResponseUtils.buildSuccess(res);
+            //} else {
+            //    //璇锋眰鎴愬姛浣嗘暟鎹负绌�
+            //    return BaseResponseUtils.buildSuccess(res);
+            //}
+            return BaseResponseUtils.buildSuccess(intakeControllerSv.getTrampControllers(vo));
         } catch (Exception e) {
             log.error("鑾峰彇娴佹氮鎺у埗鍣ㄨ褰曞紓甯�", e);
             return BaseResponseUtils.buildException(e.getMessage());
@@ -300,7 +312,7 @@
         pct.setFindDt(new Date());
         Integer rows = intakeControllerSv.addTrampController(pct);
         if (rows == 0) {
-            return BaseResponseUtils.buildFail(ProjectResultCode.ADD_TRAMP_CONTROLLER_FAIL.getMessage());
+            return BaseResponseUtils.buildErrorMsg(ProjectResultCode.ADD_TRAMP_CONTROLLER_FAIL.getMessage());
         }
         return BaseResponseUtils.buildSuccess(true);
     }
@@ -317,12 +329,30 @@
     public BaseResponse<Boolean> deleteTrampController(Long id) {
         PrControllerTramp controllerInfo = intakeControllerSv.getTrampControllerInfo(id);
         if (controllerInfo == null) {
-            return BaseResponseUtils.buildFail(ProjectResultCode.NO_EXIST_TRAMP_CONTROLLER.getMessage());
+            return BaseResponseUtils.buildErrorMsg(ProjectResultCode.NO_EXIST_TRAMP_CONTROLLER.getMessage());
         }
 
         Integer rows = intakeControllerSv.deleteTrampController(id);
+//        if (rows == 0) {
+//            return BaseResponseUtils.buildErrorMsg(ProjectResultCode.DELETE_TRAMP_CONTROLLER_FAIL.getMessage());
+//        }
+        return BaseResponseUtils.buildSuccess(true);
+    }
+
+    /**
+     * 娓呯┖娴佹氮鎺у埗鍣�
+     *
+     * @param
+     * @return
+     */
+    @PostMapping("emptyTrampController")
+    @Transactional(rollbackFor = Exception.class)
+    @SsoAop()
+    public BaseResponse<Boolean> emptyTrampController() {
+
+        Integer rows = intakeControllerSv.emptyTrampController();
         if (rows == 0) {
-            return BaseResponseUtils.buildFail(ProjectResultCode.DELETE_TRAMP_CONTROLLER_FAIL.getMessage());
+            return BaseResponseUtils.buildErrorMsg(ProjectResultCode.DELETE_TRAMP_CONTROLLER_FAIL.getMessage());
         }
         return BaseResponseUtils.buildSuccess(true);
     }

--
Gitblit v1.8.0