Переглянути джерело

update

shuiqilin-optimize
houyi 9 місяці тому
джерело
коміт
fa0257efbc

+ 19
- 16
src/main/java/com/qtzl/alterSales/manager/service/AflReportExportServiceImpl.java Переглянути файл

import com.qtzl.alterSales.manager.tools.RedisUtils; import com.qtzl.alterSales.manager.tools.RedisUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ResourceUtils; import org.springframework.util.ResourceUtils;


import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.nio.file.Files; import java.nio.file.Files;
import java.time.LocalDateTime; import java.time.LocalDateTime;
} }


private void writeExcel(String filePathAndName) throws ServiceHandleException { private void writeExcel(String filePathAndName) throws ServiceHandleException {
String templateFilePath;
ExcelWriter excelWriter;
try { try {
templateFilePath = ResourceUtils.getFile("classpath:excel-template/Byd50ServiceFeeTemplate.xlsx").getAbsolutePath();
final ClassPathResource resource = new ClassPathResource("excel-template/Byd50ServiceFeeTemplate.xlsx");
InputStream inputStream = resource.getInputStream();
excelWriter = EasyExcelFactory.write(filePathAndName).withTemplate(inputStream).build();
} catch (Exception e) { } catch (Exception e) {
throw UcServiceError.BUSINESS_VALIDATE_ERR.toHandleException(e.getMessage());
log.error("加载末班文件失败", e);
throw new NullPointerException("加载末班文件失败");
} }


ExcelWriter excelWriter = EasyExcelFactory.write(filePathAndName).withTemplate(templateFilePath).build();

// 设置策略 // 设置策略
WriteSheet class2973Pay = EasyExcelFactory.writerSheet(0, "2973收款分类").build();
WriteSheet class2973Service = EasyExcelFactory.writerSheet(1, "2973服务费分类").build();
WriteSheet class2973Refund = EasyExcelFactory.writerSheet(2, "2973退款分类").build();
WriteSheet statistics50ServiceFee = EasyExcelFactory.writerSheet(3, "比亚迪50服务费统计").build();
WriteSheet classFeeFlow = EasyExcelFactory.writerSheet(4, "部中心请款流水分类").build();
WriteSheet classRefundFlow = EasyExcelFactory.writerSheet(5, "部中心退款流水分类").build();
// WriteSheet class2973Pay = EasyExcelFactory.writerSheet(0, "2973收款分类").build();
// WriteSheet class2973Service = EasyExcelFactory.writerSheet(1, "2973服务费分类").build();
// WriteSheet class2973Refund = EasyExcelFactory.writerSheet(2, "2973退款分类").build();
WriteSheet statistics50ServiceFee = EasyExcelFactory.writerSheet(0, "比亚迪50服务费统计").build();
// WriteSheet classFeeFlow = EasyExcelFactory.writerSheet(4, "部中心请款流水分类").build();
// WriteSheet classRefundFlow = EasyExcelFactory.writerSheet(5, "部中心退款流水分类").build();


// 渲染数据到excel // 渲染数据到excel
boolean blnContinue = true; boolean blnContinue = true;
switch (queueDataBean.getDataEnum()) { switch (queueDataBean.getDataEnum()) {
case LIST_FOR_2973_DATA: case LIST_FOR_2973_DATA:
List<AflMchStatistics> list1 = (List<AflMchStatistics>) dataList; List<AflMchStatistics> list1 = (List<AflMchStatistics>) dataList;
excelWriter.fill(getClass2973PaySheet(list1), class2973Pay);
excelWriter.fill(getClass2973ServiceSheet(list1), class2973Service);
excelWriter.fill(getClass2973RefundSheet(list1), class2973Refund);
// excelWriter.fill(getClass2973PaySheet(list1), class2973Pay);
// excelWriter.fill(getClass2973ServiceSheet(list1), class2973Service);
// excelWriter.fill(getClass2973RefundSheet(list1), class2973Refund);
break; break;
case LIST_FOR_50_SERVICE_FEE_DATA: case LIST_FOR_50_SERVICE_FEE_DATA:
List<ExcelHead50ServiceFeeVO> list2 = (List<ExcelHead50ServiceFeeVO>) dataList; List<ExcelHead50ServiceFeeVO> list2 = (List<ExcelHead50ServiceFeeVO>) dataList;
break; break;
case LIST_FOR_PAY_FLOW_DATA: case LIST_FOR_PAY_FLOW_DATA:
List<ExcelHeadFlowClassificationVO> list3 = (List<ExcelHeadFlowClassificationVO>) dataList; List<ExcelHeadFlowClassificationVO> list3 = (List<ExcelHeadFlowClassificationVO>) dataList;
excelWriter.fill(getClassFlowSheet(list3), classFeeFlow);
// excelWriter.fill(getClassFlowSheet(list3), classFeeFlow);
break; break;
case LIST_FOR_REFUND_FLOW_DATA: case LIST_FOR_REFUND_FLOW_DATA:
List<ExcelHeadFlowClassificationVO> list4 = (List<ExcelHeadFlowClassificationVO>) dataList; List<ExcelHeadFlowClassificationVO> list4 = (List<ExcelHeadFlowClassificationVO>) dataList;
excelWriter.fill(getClassFlowSheet(list4), classRefundFlow);
// excelWriter.fill(getClassFlowSheet(list4), classRefundFlow);
break; break;
case DATA_PUSH_SUCCESS: case DATA_PUSH_SUCCESS:
printDataHandleFinishInfo(); printDataHandleFinishInfo();

Завантаження…
Відмінити
Зберегти