From a6efc98ddf0afc935ad88d91f8817f5fc2593169 Mon Sep 17 00:00:00 2001
From: lyh <925863403@qq.com>
Date: 星期二, 08 七月 2025 20:32:25 +0800
Subject: [PATCH] 设备表-通过EAM中心ids获取设备树

---
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java |   42 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java
index 31595fe..5a19efb 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java
@@ -11,10 +11,13 @@
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.TranslateDictTextUtils;
+import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.eam.entity.EamEquipment;
 import org.jeecg.modules.eam.entity.EamEquipmentExtend;
 import org.jeecg.modules.eam.request.EamEquipmentQuery;
@@ -25,7 +28,10 @@
 //import org.jeecg.modules.mdc.entity.MdcEquipment;
 //import org.jeecg.modules.mdc.service.IMdcEquipmentService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
 import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -38,6 +44,7 @@
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 璁惧鍙拌处
@@ -198,13 +205,26 @@
 
     /**
      * 瀵煎嚭excel
-     *
-     * @param request
      * @param eamEquipment
      */
     @RequestMapping(value = "/exportXls")
-    public ModelAndView exportXls(HttpServletRequest request, EamEquipment eamEquipment) {
-        return super.exportXls(request, eamEquipment, EamEquipment.class, "璁惧鍙拌处");
+    public ModelAndView exportXls(HttpServletRequest request,EamEquipmentQuery eamEquipment) {
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        List<EamEquipment> equipmentList=eamEquipmentService.exportList(eamEquipment);
+        String selections = request.getParameter("selections");
+        if (oConvertUtils.isNotEmpty(selections)) {
+            List<String> selectionList = Arrays.asList(selections.split(","));
+            equipmentList = equipmentList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
+        }
+
+        // Step.3 AutoPoi 瀵煎嚭Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        mv.addObject(NormalExcelConstants.FILE_NAME, "璁惧鍙拌处"); //姝ゅ璁剧疆鐨刦ilename鏃犳晥 ,鍓嶇浼氶噸鏇存柊璁剧疆涓�涓�
+        mv.addObject(NormalExcelConstants.CLASS, EamEquipment.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("璁惧鍙拌处" + "鎶ヨ〃", "瀵煎嚭浜�:" + sysUser.getRealname(), "璁惧鍙拌处"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, equipmentList);
+        return mv;
+
     }
 
     /**
@@ -296,6 +316,20 @@
         return result;
     }
 
+    @ApiOperation(value = "璁惧琛�-閫氳繃EAM涓績ids鑾峰彇璁惧鏍�", notes = "璁惧琛�-閫氳繃EAM涓績ids鑾峰彇璁惧鏍�")
+    @GetMapping(value = "/loadTreeListByEamCenterIds")
+    public Result<List<EamEquipmentTree>> loadTreeListByEamCenterIds(@RequestParam(name = "ids", required = true) String ids) {
+        Result<List<EamEquipmentTree>> result = new Result<>();
+        try {
+            List<EamEquipmentTree> mdcEquipmentTreeList = eamEquipmentService.loadTreeListByEamCenterIds(ids);
+            result.setSuccess(true);
+            result.setResult(mdcEquipmentTreeList);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+        return result;
+    }
+
     /**
      * 妫�绱㈣澶�
      * @param keyword 鏌ヨ鍏抽敭璇� 璁惧缂栧彿锛岃澶囧悕绉版ā绯婂尮閰�

--
Gitblit v1.9.3