Browse Source

导入导出

2024年10月18日16:43:02
thing_master
lishuai 1 year ago
parent
commit
91a0b7af02
  1. 7
      modules/thing/src/main/java/com/thing/thing/relation/detail/controller/IotThingRelationDetailController.java
  2. 4
      modules/thing/src/main/java/com/thing/thing/relation/detail/excel/IotThingRelationDetailExcel.java
  3. 20
      modules/thing/src/main/java/com/thing/thing/relation/detail/service/impl/IotThingRelationDetailServiceImpl.java

7
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<String, Object> params, HttpServletResponse response) throws Exception {
if(ArrayUtils.isNotEmpty(ids)){
params.put("ids",ids);
}
public void export(@RequestParam Map<String, Object> 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);
}

4
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;

20
modules/thing/src/main/java/com/thing/thing/relation/detail/service/impl/IotThingRelationDetailServiceImpl.java

@ -995,15 +995,25 @@ public class IotThingRelationDetailServiceImpl extends BaseServiceImpl<IotThingR
throw new SysException("当前关系无详情,无需导出物物关系列表");
}
List<IotThingRelationDetailExcel> 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<IotThingR
excel.setTag("下级节点名称-标签");
excel.setRemark("备注");
excel.setUrl("图片地址");
ExcelUtils.exportExcel(Lists.newArrayList(excel), "物关系详情信息", "物关系详情", IotThingViewExcel.class, "物关系详情模板.xls", response);
ExcelUtils.exportExcel(Lists.newArrayList(excel), "物关系详情信息", "物关系详情", IotThingRelationDetailExcel.class, "物关系详情模板.xls", response);
}
@Override

Loading…
Cancel
Save