Browse Source

联建单位导出

dev
yinzuomei 3 years ago
parent
commit
c1d3bdee28
  1. 5
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcPartyUnitDTO.java
  2. 7
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/PartyUnitFormDTO.java
  3. 67
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyUnitController.java
  4. 41
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcPartyUnitExcel.java
  5. 6
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java

5
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcPartyUnitDTO.java

@ -86,6 +86,11 @@ public class IcPartyUnitDTO implements Serializable {
*/
private List<String> serviceMatterNameList;
/**
* 服务事项名称多个按照中文顿号隔开
*/
private String serviceMatterName;
/**
* 联系人
*/

7
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/PartyUnitFormDTO.java

@ -1,5 +1,6 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.dto.form.PageFormDTO;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -12,7 +13,7 @@ import java.io.Serializable;
*/
@NoArgsConstructor
@Data
public class PartyUnitFormDTO implements Serializable {
public class PartyUnitFormDTO extends PageFormDTO implements Serializable {
private static final long serialVersionUID = 1256798619648265622L;
private String customerId;
@ -22,8 +23,8 @@ public class PartyUnitFormDTO implements Serializable {
private String type;
private String contact;
private String contactMobile;
private Integer pageNo;
private Integer pageSize;
// private Integer pageNo;
// private Integer pageSize;
/**
* 工作端当前登录人员

67
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcPartyUnitController.java

@ -1,16 +1,24 @@
package com.epmet.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.epmet.commons.rocketmq.messages.ServerSatisfactionCalFormDTO;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.result.OptionDataResultDTO;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
@ -28,6 +36,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
@ -40,11 +49,9 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@ -64,11 +71,6 @@ public class IcPartyUnitController {
@Resource
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
/**
* 联建单位上传临时目录
*/
private Path IC_PARTY_UNIT_UPLOAD_DIR;
/**
* 联建单位-列表查询
@ -122,25 +124,38 @@ public class IcPartyUnitController {
@PostMapping("export")
public void export(@LoginUser TokenDto tokenDto, @RequestBody PartyUnitFormDTO formDTO, HttpServletResponse response) throws Exception {
formDTO.setCustomerId(tokenDto.getCustomerId());
List<IcPartyUnitDTO> list = icPartyUnitService.list(formDTO);
List<IcPartyUnitExcel> excelList = new ArrayList<>();
AtomicInteger i = new AtomicInteger(1);
if (CollectionUtils.isNotEmpty(list)) {
excelList = list.stream().map(item -> {
IcPartyUnitExcel excel = new IcPartyUnitExcel();
excel.setIndex(i.getAndIncrement());
excel.setUnitName(item.getUnitName());
excel.setContact(item.getContact());
excel.setContactMobile(item.getContactMobile());
excel.setType(item.getType());
excel.setMemberCount(item.getMemberCount());
excel.setRemark(item.getRemark());
excel.setSatisfaction(item.getSatisfaction());
excel.setServiceMatter(String.join(String.valueOf((char) 10), item.getServiceMatterList()));
return excel;
}).collect(Collectors.toList());
formDTO.setIsPage(false);
formDTO.setCurrentStaffId(tokenDto.getUserId());
ExcelWriter excelWriter = null;
formDTO.setPageSize(NumConstant.TEN_THOUSAND);
int pageNo = formDTO.getPageNo();
try {
// 这里 需要指定写用哪个class去写
String today= DateUtils.format(new Date(),DateUtils.DATE_PATTERN_MMDD);
String fileName = "行程上报信息".concat(today);
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcPartyUnitExcel.class).build();
WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build();
PageData<IcPartyUnitDTO> data = null;
List<IcPartyUnitExcel> list = null;
do {
data = icPartyUnitService.search(formDTO);
data.getList().stream().map(item -> {
item.setServiceMatterName(StringUtils.join(item.getServiceMatterList(), StrConstant.COMMA_ZH));
return item;
}).collect(Collectors.toList());
list = ConvertUtils.sourceToTarget(data.getList(), IcPartyUnitExcel.class);
formDTO.setPageNo(++pageNo);
excelWriter.write(list, writeSheet);
} while (CollectionUtils.isNotEmpty(data.getList()) && data.getList().size() == formDTO.getPageSize());
} catch (Exception e) {
log.error("export exception", e);
} finally {
// 千万别忘记finish 会帮忙关闭流
if (excelWriter != null) {
excelWriter.finish();
}
}
ExcelUtils.exportExcelToTarget(response, null, excelList, IcPartyUnitExcel.class);
}
/**

41
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/IcPartyUnitExcel.java

@ -17,7 +17,8 @@
package com.epmet.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
/**
@ -29,30 +30,42 @@ import lombok.Data;
@Data
public class IcPartyUnitExcel {
@Excel(name = "序号")
private Integer index;
@Excel(name = "单位名称")
@ColumnWidth(30)
@ExcelProperty(value = "单位名称")
private String unitName;
@Excel(name = "分类")
private String type;
@ColumnWidth(25)
@ExcelProperty(value = "所属组织")
private String agencyName;
@ColumnWidth(25)
@ExcelProperty(value = "分类")
private String typeName;
@Excel(name = "服务事项")
private String serviceMatter;
/**
* 服务事项名称多个按照中文顿号隔开
*/
@ColumnWidth(100)
@ExcelProperty(value = "服务事项")
private String serviceMatterName;
@Excel(name = "联系人")
@ColumnWidth(16)
@ExcelProperty(value = "联系人")
private String contact;
@Excel(name = "联系电话")
@ColumnWidth(16)
@ExcelProperty(value = "联系电话")
private String contactMobile;
@Excel(name = "在职党员")
@ColumnWidth(18)
@ExcelProperty(value = "在职党员数")
private Integer memberCount;
@Excel(name = "群众满意度")
@ColumnWidth(18)
@ExcelProperty(value = "群众满意度")
private String satisfaction;
@Excel(name = "备注")
@ColumnWidth(100)
@ExcelProperty(value = "备注")
private String remark;
}

6
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java

@ -145,6 +145,8 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPa
//获取单位积分
Map<String, Integer> pointMap = icUserDemandRecService.getServicePoint(formDTO.getCustomerId(), UserDemandConstant.PARTY_UNIT);
dtoList.forEach(item -> {
item.setTypeName(unitTypeMap.getData().get(item.getType()));
//这是错误的,应该是赋值type,遗留bug, 先不改了....
item.setType(unitTypeMap.getData().get(item.getType()));
if (StringUtils.isNotBlank(item.getServiceMatter())) {
List<String> matters = Arrays.asList(item.getServiceMatter().split(StrConstant.COMMA));
@ -183,6 +185,8 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPa
//获取单位积分
Map<String, Integer> pointMap = icUserDemandRecService.getServicePoint(formDTO.getCustomerId(), UserDemandConstant.PARTY_UNIT);
dtoList.forEach(item -> {
item.setTypeName(unitTypeMap.getData().get(item.getType()));
//这是错误的,应该是赋值type,遗留bug, 先不改了....
item.setType(unitTypeMap.getData().get(item.getType()));
if (StringUtils.isNotBlank(item.getServiceMatter())) {
List<String> matters = Arrays.asList(item.getServiceMatter().split(StrConstant.COMMA));
@ -217,6 +221,8 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPa
//获取分类名称字典
Result<Map<String, String>> typeDictMapRes=epmetAdminOpenFeignClient.dictMap(DictTypeEnum.PARTY_UNIT_TYPE.getCode());
Map<String, String> typeDictMap = typeDictMapRes.success() && MapUtils.isNotEmpty(typeDictMapRes.getData()) ? typeDictMapRes.getData() : new HashMap<>();
dto.setTypeName(MapUtils.isNotEmpty(typeDictMap) && typeDictMap.containsKey(dto.getType()) ? typeDictMap.get(dto.getType()) : StrConstant.EPMETY_STR);
//这是错误的,应该是赋值type,遗留bug, 先不改了....
dto.setType(MapUtils.isNotEmpty(typeDictMap) && typeDictMap.containsKey(dto.getType()) ? typeDictMap.get(dto.getType()) : StrConstant.EPMETY_STR);
// 服务事项
if(CollectionUtils.isNotEmpty(dto.getServiceMatterList())){

Loading…
Cancel
Save