From 91a0b7af027abde1896b2392189d704d8da4d01d Mon Sep 17 00:00:00 2001 From: lishuai Date: Fri, 18 Oct 2024 16:43:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA=202024?= =?UTF-8?q?=E5=B9=B410=E6=9C=8818=E6=97=A516:43:02?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IotThingRelationDetailController.java | 7 ++----- .../excel/IotThingRelationDetailExcel.java | 4 ++++ .../IotThingRelationDetailServiceImpl.java | 20 ++++++++++++++----- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/modules/thing/src/main/java/com/thing/thing/relation/detail/controller/IotThingRelationDetailController.java b/modules/thing/src/main/java/com/thing/thing/relation/detail/controller/IotThingRelationDetailController.java index dad35a6..e5470de 100644 --- a/modules/thing/src/main/java/com/thing/thing/relation/detail/controller/IotThingRelationDetailController.java +++ b/modules/thing/src/main/java/com/thing/thing/relation/detail/controller/IotThingRelationDetailController.java @@ -203,16 +203,13 @@ public class IotThingRelationDetailController { @PostMapping("export") @Operation(summary="物关系导出") @LogOperation("物关系导出") - public void export(@RequestBody Long[] ids, @RequestParam Map params, HttpServletResponse response) throws Exception { - if(ArrayUtils.isNotEmpty(ids)){ - params.put("ids",ids); - } + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { service.exportExcel(params,response); } @PostMapping("template") @Operation(summary="物关系模板下载") - public void exportTemplate(HttpServletResponse response) { + public void template(HttpServletResponse response) throws Exception { service.template(response); } diff --git a/modules/thing/src/main/java/com/thing/thing/relation/detail/excel/IotThingRelationDetailExcel.java b/modules/thing/src/main/java/com/thing/thing/relation/detail/excel/IotThingRelationDetailExcel.java index 3c6dc26..398077f 100644 --- a/modules/thing/src/main/java/com/thing/thing/relation/detail/excel/IotThingRelationDetailExcel.java +++ b/modules/thing/src/main/java/com/thing/thing/relation/detail/excel/IotThingRelationDetailExcel.java @@ -18,6 +18,7 @@ import java.io.Serializable; * @author xc/ls * @since 3.0 2023-06-05 */ + @Data @Accessors(chain = true) @EqualsAndHashCode(callSuper=false) @@ -25,6 +26,9 @@ import java.io.Serializable; @AllArgsConstructor public class IotThingRelationDetailExcel implements Serializable { + @Serial + private static final long serialVersionUID = 1L; + @Excel(name = "关系名称",width = 25) private String name; diff --git a/modules/thing/src/main/java/com/thing/thing/relation/detail/service/impl/IotThingRelationDetailServiceImpl.java b/modules/thing/src/main/java/com/thing/thing/relation/detail/service/impl/IotThingRelationDetailServiceImpl.java index b3fd3f4..dda8c9c 100644 --- a/modules/thing/src/main/java/com/thing/thing/relation/detail/service/impl/IotThingRelationDetailServiceImpl.java +++ b/modules/thing/src/main/java/com/thing/thing/relation/detail/service/impl/IotThingRelationDetailServiceImpl.java @@ -995,15 +995,25 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl resList = list.stream().map(node -> { - IotThingRelationDetailExcel excel = JacksonUtil.convertValue(node, IotThingRelationDetailExcel.class); + IotThingRelationDetailExcel excel = new IotThingRelationDetailExcel(); + excel.setFromName(node.get("fromName").asText()); + excel.setFromCode(node.get("fromCode").asText()); + excel.setToName(node.get("toName").asText()); + excel.setToCode(node.get("toCode").asText()); + excel.setConfig(node.get("config").isEmpty() ? "" : node.get("config").asText()); + excel.setRemark(node.get("remark").isEmpty() ? "" : node.get("remark").asText()); + excel.setSort(node.get("sort").asLong()); + excel.setUrl(node.get("url").isEmpty() ? "" : node.get("url").asText()); + excel.setTag(node.get("tag").isEmpty() ? "" : node.get("tag").asText()); long rootThingId = node.get("rootThingId").asLong(); IotThingEntityInfoDTO entity = thingEntitiesService.findEntityById(rootThingId); excel.setRootThingCode(entity.getCode()); + long rootId = node.get("rootId").asLong(); + IotThingRelationRootDTO rootDTO = relationRootsService.findById(rootId); + excel.setName(rootDTO.getName()); return excel; }).toList(); - - ExcelUtils.exportExcel(resList, "物关系详情信息", "物关系详情", IotThingViewExcel.class, "物关系详情模板.xls", response); - + ExcelUtils.exportExcel(new ArrayList<>(resList), "物关系详情信息", "物关系详情", IotThingRelationDetailExcel.class, "物关系详情模板.xls", response); } @Override @@ -1072,7 +1082,7 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl