添加功能
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.ruoyi.cms.service;
|
||||
|
||||
import com.ruoyi.cms.domain.dto.QueryParamDto;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 分析导出
|
||||
*
|
||||
* @author 马宝龙
|
||||
* @date 2026/6/27
|
||||
*/
|
||||
public interface AnalysisExportService {
|
||||
|
||||
|
||||
/**
|
||||
* 数据导出
|
||||
*
|
||||
* @param response 响应
|
||||
* @param dto 查询参数
|
||||
*/
|
||||
void exportData(HttpServletResponse response, QueryParamDto dto);
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.ruoyi.cms.service.impl;
|
||||
|
||||
import com.ruoyi.cms.domain.dto.ExcelRow;
|
||||
import com.ruoyi.cms.domain.dto.QueryParamDto;
|
||||
import com.ruoyi.cms.service.AnalysisExportService;
|
||||
import com.ruoyi.cms.util.document.ExcelUtil;
|
||||
import com.ruoyi.cms.util.document.MultiSheetExcelUtil;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 分析导出
|
||||
*
|
||||
* @author 马宝龙
|
||||
* @date 2026/6/27
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class AnalysisExportServiceImpl implements AnalysisExportService {
|
||||
@Override
|
||||
public void exportData(HttpServletResponse response, QueryParamDto dto) {
|
||||
if (Objects.isNull(dto.getExportModule())) {
|
||||
throw new ServiceException("请选择导出模块");
|
||||
}
|
||||
try {
|
||||
switch (dto.getExportModule()) {
|
||||
// 就业大数据专题分析平台-行业就业情况信息分析
|
||||
case EMPLOYMENT_INDUSTRY_EMPLOYMENT_INFO:
|
||||
test(response, dto);
|
||||
break;
|
||||
// 就业大数据专题分析平台-高校毕业生就业信息分析
|
||||
case EMPLOYMENT_GRADUATE_EMPLOYMENT_INFO:
|
||||
test(response, dto);
|
||||
break;
|
||||
// 就业大数据专题分析平台-重点行业就失业监测分析
|
||||
case EMPLOYMENT_MAJOR_INDUSTRY_EMPLOYMENT_MONITOR:
|
||||
test(response, dto);
|
||||
break;
|
||||
// 就业大数据专题分析平台-产业发展与人才供需分析
|
||||
case EMPLOYMENT_SECTOR_TALENT:
|
||||
test(response, dto);
|
||||
break;
|
||||
// 就业大数据专题分析平台-产业发展与职业技能提升分析
|
||||
case EMPLOYMENT_SECTOR_OCCUPATION_SKILL:
|
||||
test(response, dto);
|
||||
break;
|
||||
// 就业大数据专题分析平台-岗位需求趋势变化分析
|
||||
case EMPLOYMENT_JOB_DEMAND_TREAD:
|
||||
test(response, dto);
|
||||
break;
|
||||
// 就业大数据专题分析平台-重点人群跟踪服务情况分析
|
||||
case EMPLOYMENT_KEY_GROUP_SERVICE_SITUATION:
|
||||
test(response, dto);
|
||||
break;
|
||||
// 智慧就业大数据分析展示系统-行业就业情况信息分析
|
||||
case WISDOM_EMPLOYMENT_INDUSTRY_EMPLOYMENT_INFO:
|
||||
test(response, dto);
|
||||
break;
|
||||
// 智慧就业大数据分析展示系统-高校毕业生就业信息分析
|
||||
case WISDOM_EMPLOYMENT_GRADUATE_EMPLOYMENT_INFO:
|
||||
test(response, dto);
|
||||
break;
|
||||
// 智慧就业大数据分析展示系统-重点行业就失业监测分析
|
||||
case WISDOM_EMPLOYMENT_MAJOR_INDUSTRY_EMPLOYMENT_MONITOR:
|
||||
test(response, dto);
|
||||
break;
|
||||
// 智慧就业大数据分析展示系统-产业与人才供需技能提升分析
|
||||
case WISDOM_EMPLOYMENT_SECTOR_TALENT_SKILL:
|
||||
test(response, dto);
|
||||
break;
|
||||
// 智慧就业大数据分析展示系统-重点人群跟踪服务情况分析
|
||||
case WISDOM_EMPLOYMENT_KEY_GROUP_SERVICE_SITUATION:
|
||||
test(response, dto);
|
||||
break;
|
||||
// 智慧就业大数据分析展示系统-劳动力就业失业数据分析
|
||||
case WISDOM_EMPLOYMENT_LABOR_FORCE_EMPLOYMENT:
|
||||
test(response, dto);
|
||||
break;
|
||||
// 可以添加更多导出格式的处理
|
||||
default:
|
||||
throw new ServiceException("暂不支持该模块");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("导出失败:", e);
|
||||
throw new ServiceException("导出失败,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
private void test(HttpServletResponse response, QueryParamDto dto) throws IOException {
|
||||
MultiSheetExcelUtil multiSheetExcelUtil = test(dto);
|
||||
multiSheetExcelUtil.setFileName(dto.getExportModule().getDesc());
|
||||
multiSheetExcelUtil.exportExcel(response);
|
||||
|
||||
}
|
||||
|
||||
private MultiSheetExcelUtil test(QueryParamDto dto) {
|
||||
// 1. 创建多工作表Excel工具
|
||||
MultiSheetExcelUtil multiSheetExcelUtil = new MultiSheetExcelUtil();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String exportTime = DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS);
|
||||
List<ExcelRow> basicExportList = new ArrayList<>();
|
||||
basicExportList.add(new ExcelRow("导出时间", exportTime));
|
||||
basicExportList.add(new ExcelRow("数据总览"));
|
||||
basicExportList.add(new ExcelRow("测试1", "测试2", "测试3", "测试4", "测试5"));
|
||||
basicExportList.add(new ExcelRow(
|
||||
"1", "1", "1", "1", "1"
|
||||
));
|
||||
basicExportList.add(new ExcelRow(
|
||||
"2", "2", "2", "2", "2"
|
||||
));
|
||||
basicExportList.add(new ExcelRow(
|
||||
"3", "3", "3", "3", "3"
|
||||
));
|
||||
|
||||
// 创建Excel工具类并添加工作表
|
||||
ExcelUtil<ExcelRow> basicSituationExcelUtil = new ExcelUtil<>(ExcelRow.class);
|
||||
basicSituationExcelUtil.setDataList(basicExportList);
|
||||
basicSituationExcelUtil.setSheetName("测试数据");
|
||||
multiSheetExcelUtil.addSheet(basicSituationExcelUtil);
|
||||
|
||||
return multiSheetExcelUtil;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user