From a2b688a360646d057f47cb053f10e919204f9c9d Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 24 Nov 2021 09:55:09 +0800 Subject: [PATCH] export --- ...IcCommunitySelfOrganizationController.java | 7 +++++ .../ExportCommunitySelfOrganizationExcel.java | 31 +++++++++++++++++++ ...cCommunitySelfOrganizationServiceImpl.java | 27 +++++++++++----- 3 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/ExportCommunitySelfOrganizationExcel.java diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java index 0a52e569ff..0b6b831aff 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java @@ -35,6 +35,7 @@ import com.epmet.dto.form.EditCommunitySelfOrganizationFormDTO; import com.epmet.dto.form.demand.ServiceQueryFormDTO; import com.epmet.dto.result.CommunitySelfOrganizationListResultDTO; import com.epmet.dto.result.demand.OptionDTO; +import com.epmet.excel.ExportCommunitySelfOrganizationExcel; import com.epmet.excel.IcCommunitySelfOrganizationExcel; import com.epmet.service.IcCommunitySelfOrganizationService; import org.springframework.beans.factory.annotation.Autowired; @@ -100,6 +101,12 @@ public class IcCommunitySelfOrganizationController { ExcelUtils.exportExcelToTarget(response, null, list, IcCommunitySelfOrganizationExcel.class); } + @PostMapping("exportcommunityselforganization") + public void exportCommunitySelfOrganization(HttpServletResponse response,@LoginUser TokenDto tokenDto,@RequestBody CommunitySelfOrganizationListFormDTO formDTO) throws Exception { + CommunitySelfOrganizationListResultDTO resultDTO = icCommunitySelfOrganizationService.communitySelfOrganizationList(tokenDto, formDTO); + ExcelUtils.exportExcelToTarget(response, null, resultDTO.getList(), ExportCommunitySelfOrganizationExcel.class); + } + /** * @Description 添加社区自组织 * @param tokenDto diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/ExportCommunitySelfOrganizationExcel.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/ExportCommunitySelfOrganizationExcel.java new file mode 100644 index 0000000000..d8020a3345 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/ExportCommunitySelfOrganizationExcel.java @@ -0,0 +1,31 @@ +package com.epmet.excel; + +import cn.afterturn.easypoi.excel.annotation.CellStyler; +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +@Data +public class ExportCommunitySelfOrganizationExcel { + + @Excel(name = "排序") + private Integer sort; + + @Excel(name = "组织名称", width = 40) + private String organizationName; + + @Excel(name = "组织人数", width = 20) + private Integer organizationPersonCount; + + @Excel(name = "负责人姓名", width = 20) + private String principalName; + + @Excel(name = "负责人电话", width = 20) + private String principalPhone; + + @Excel(name = "服务事项", width = 60) + private String serviceItem; + + @Excel(name = "社区自组织创建时间", width = 20) + private String organizationCreatedTime; + +} \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java index f99b3133df..fcc0448fe4 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java @@ -43,6 +43,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.*; +import java.util.concurrent.atomic.AtomicReference; import static com.epmet.commons.tools.utils.DateUtils.DATE_PATTERN; @@ -213,14 +214,26 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl objectPageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()).doSelectPageInfo(() -> baseDao.selectCommunitySelfOrganizationList(formDTO)); - result.setTotal(Integer.valueOf(String.valueOf(objectPageInfo.getTotal()))); - if (CollectionUtils.isNotEmpty(objectPageInfo.getList())){ - objectPageInfo.getList().forEach(l -> { - l.setSort(i[NumConstant.ZERO]); - i[NumConstant.ZERO]++; + if (formDTO.getIsPage()){ + PageInfo objectPageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectCommunitySelfOrganizationList(formDTO)); + result.setTotal(Integer.valueOf(String.valueOf(objectPageInfo.getTotal()))); + if (CollectionUtils.isNotEmpty(objectPageInfo.getList())){ + objectPageInfo.getList().forEach(l -> { + l.setSort(i[NumConstant.ZERO]); + i[NumConstant.ZERO]++; + }); + result.setList(objectPageInfo.getList()); + } + return result; + } + List resultDTOs = baseDao.selectCommunitySelfOrganizationList(formDTO); + if (CollectionUtils.isNotEmpty(resultDTOs)){ + result.setTotal(resultDTOs.size()); + AtomicReference sort = new AtomicReference<>(NumConstant.ONE); + resultDTOs.forEach(r -> { + r.setSort(sort.getAndSet(sort.get() + NumConstant.ONE)); }); - result.setList(objectPageInfo.getList()); + result.setList(resultDTOs); } return result; }