Browse Source

代码暂存

release
jianjun 3 years ago
parent
commit
4d1f03f219
  1. 20
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserExportServiceImpl.java

20
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserExportServiceImpl.java

@ -3,6 +3,9 @@ package com.epmet.service.impl;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.Constant;
import com.epmet.commons.tools.constant.NumConstant;
@ -35,6 +38,7 @@ import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.jetbrains.annotations.Nullable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -73,6 +77,14 @@ public class IcResiUserExportServiceImpl implements IcResiUserExportService {
*/
@Override
public void exportIcResiUser(IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) {
// 头的策略
WriteCellStyle headWriteCellStyle = new WriteCellStyle();
// 背景设置为红色
headWriteCellStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle,new WriteCellStyle());
ExcelWriter excelWriter = null;
try {
//获取用户配置的导出条件
@ -83,7 +95,10 @@ public class IcResiUserExportServiceImpl implements IcResiUserExportService {
log.info("查询到的模板配置信息:{}", JSON.toJSONString(exportConfigData));
FreezeAndFilter writeHandler = new FreezeAndFilter();
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel("居民基本信息.xlsx", response)).registerWriteHandler(writeHandler).build();
WriteSheet writeSheet = EasyExcel.writerSheet().head(exportConfigData.getHeaders()).build();
WriteSheet writeSheet = EasyExcel.writerSheet()
.registerWriteHandler(horizontalCellStyleStrategy)
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
.head(exportConfigData.getHeaders()).build();
CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(pageFormDTO.getCustomerId(), pageFormDTO.getStaffId());
if (staffInfoCacheResult == null){
@ -199,6 +214,7 @@ public class IcResiUserExportServiceImpl implements IcResiUserExportService {
} else {
String[] parts = icResiUserImportService.splitOptionSourceUrl(e.getOptionSourceValue());
//todo 不支持多个itemId
Map<String, String> remoteOptions = icResiUserImportService.listRemoteOptions(parts[0], parts[1], columnWrappers, currentStaffAgencyId, "query");
log.info("========putRemoteValue:条件:{}", JSON.toJSONString(columnWrappers));
log.info("========putRemoteValue:结果:{}", JSON.toJSONString(remoteOptions));
@ -229,7 +245,7 @@ public class IcResiUserExportServiceImpl implements IcResiUserExportService {
valueList.add(option.getLabel());
}
});
return Joiner.on(",").join(valueList);
return Joiner.on("").join(valueList);
}
for (OptionDTO dto : e.getOptions()) {

Loading…
Cancel
Save