From 4b3f119b61143fed474b9dfcafd2369fc558a3b9 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期三, 07 五月 2025 15:06:52 +0800
Subject: [PATCH] 添加分页获取未删除阀控器列表接口

---
 pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java |   48 +++++++++++++++++++++++++++++++-----------------
 1 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java
index bcbae33..161a2d3 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/controller/ControllerCtrl.java
@@ -1,16 +1,18 @@
 package com.dy.pipIrrProject.controller;
 
-import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.excel.EasyExcel;
-import com.alibaba.excel.support.ExcelTypeEnum;
+import com.alibaba.fastjson2.JSONArray;
 import com.dy.common.aop.SsoAop;
 import com.dy.common.webUtil.BaseResponse;
 import com.dy.common.webUtil.BaseResponseUtils;
 import com.dy.common.webUtil.QueryResultVo;
 import com.dy.common.webUtil.ResultCodeMsg;
+import com.dy.pipIrrGlobal.excel.CellWriteHandler;
+import com.dy.pipIrrGlobal.excel.ExcelUtil;
 import com.dy.pipIrrGlobal.pojoBa.BaClient;
 import com.dy.pipIrrGlobal.pojoPr.PrController;
 import com.dy.pipIrrGlobal.voPr.VoController;
+import com.dy.pipIrrGlobal.voPr.VoControllerSimple;
 import com.dy.pipIrrGlobal.voSe.VoActiveCard;
 import com.dy.pipIrrProject.result.ProjectResultCode;
 import io.swagger.v3.oas.annotations.Operation;
@@ -32,6 +34,7 @@
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
+import java.time.LocalDate;
 import java.util.*;
 
 /**
@@ -102,7 +105,7 @@
         try {
             List<Map<String, Object>> list = Optional.ofNullable(controllerSv.getControllersByAddr(rtuAddr)).orElse(new ArrayList<>());
             if (list.size() <= 0) {
-                return BaseResponseUtils.buildFail(ProjectResultCode.NO_RECORDS.getMessage());
+                return BaseResponseUtils.buildErrorMsg(ProjectResultCode.NO_RECORDS.getMessage());
             }
             return BaseResponseUtils.buildSuccess(list);
         } catch (Exception e) {
@@ -133,7 +136,7 @@
     //public BaseResponse<Boolean> add(@RequestBody @Valid DtoController po, BindingResult bindingResult){
     public BaseResponse<Boolean> add(@RequestBody @Valid PrController po, BindingResult bindingResult) {
         if (bindingResult != null && bindingResult.hasErrors()) {
-            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+            return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
         }
 
         //PrController prController = DtoToPojo.INSTANCT.po2vo(po);
@@ -151,7 +154,7 @@
         }
         Integer rec = Optional.ofNullable(controllerSv.addController(po)).orElse(0);
         if (rec == 0) {
-            return BaseResponseUtils.buildFail(ProjectResultCode.CONTROLLER_FAIL.getMessage());
+            return BaseResponseUtils.buildErrorMsg(ProjectResultCode.CONTROLLER_FAIL.getMessage());
         }
         return BaseResponseUtils.buildSuccess(true);
     }
@@ -175,13 +178,13 @@
     @SsoAop()
     public BaseResponse<Boolean> delete(@RequestBody Map map) {
         if (map == null || map.size() <= 0) {
-            return BaseResponseUtils.buildFail(ProjectResultCode.PLEASE_INPUT_CONTROLLER_ID.getMessage());
+            return BaseResponseUtils.buildErrorMsg(ProjectResultCode.PLEASE_INPUT_CONTROLLER_ID.getMessage());
         }
 
         Long controllerId = Long.parseLong(map.get("controllerId").toString());
         Integer recordCount = Optional.ofNullable(controllerSv.deleteControllerById(controllerId)).orElse(0);
         if (recordCount == 0) {
-            return BaseResponseUtils.buildFail(ProjectResultCode.DELETE_CONTROLLER_FAIL.getMessage());
+            return BaseResponseUtils.buildErrorMsg(ProjectResultCode.DELETE_CONTROLLER_FAIL.getMessage());
         }
         return BaseResponseUtils.buildSuccess(true);
     }
@@ -224,15 +227,12 @@
     @SneakyThrows(IOException.class)
     @RequestMapping(value = "/export", method = RequestMethod.GET)
     public void export(HttpServletResponse response, QueryVo vo) {
-        setExcelRespProp(response, "鎺у埗鍣ㄥ垪琛�");
-        //List<VoDivide> memberList = LocalJsonUtil.getListFromJson("json/members.json", VoDivide.class);
-        List<VoController> memberList = controllerSv.export(vo);
-
-        EasyExcel.write(response.getOutputStream())
-                .head(VoController.class)
-                .excelType(ExcelTypeEnum.XLSX)
-                .sheet("鎺у埗鍣ㄥ垪琛�")
-                .doWrite(memberList);
+        List<VoController> controllerList = controllerSv.export(vo);
+        ExcelUtil.setExcelRespProp(response, "鎺у埗鍣ㄥ垪琛�" + LocalDate.now());
+        EasyExcel.write(response.getOutputStream(), VoController.class)
+                .registerWriteHandler(new CellWriteHandler("鎺у埗鍣ㄥ垪琛�"))
+                .sheet("鎺у埗鍣�")
+                .doWrite(controllerList);
     }
 
     /**
@@ -245,5 +245,19 @@
         response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
     }
 
-
+    /**
+     * 涓嶅垎椤佃幏鍙栧叏閮ㄦ湭鍒犻櫎鐨勯榾鎺у櫒鍒楄〃
+     * @return
+     */
+    @GetMapping(path = "/getSimpleControllers")
+    @SsoAop()
+    public BaseResponse<List<VoControllerSimple>> getSimpleControllers() {
+        try {
+            List<VoControllerSimple> res = controllerSv.getSimpleControllers();
+            return BaseResponseUtils.buildSuccess(res);
+        } catch (Exception e) {
+            log.error("鑾峰彇鏈畬鐨勮鍒掑紓甯�", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+    }
 }

--
Gitblit v1.8.0