导出excel

@Override
public Workbook excel(List ids, HttpServletResponse response) {
SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);
QueryWrapper wrapper = new QueryWrapper<>();
wrapper.in(“id”,ids);
List proceedings = proceedingMapper.selectList(wrapper);
if(Objects.isNull(proceedings)||proceedings.size()==0){
throw new SupervisionOpenException(SystemErrorInfo.DATA_NOT_EXIST_ERROR);
}
List list = new ArrayList<>();
List maps = new ArrayList<>();
for (Proceeding proceeding : proceedings) {
ProceedingExcelDTO proceedingExcelDTO = new ProceedingExcelDTO();
BeanUtils.copyProperties(proceeding, proceedingExcelDTO);
if(DelayFlag.NOT_DELAY.getCode().equals(proceeding.getDelayFlag())){
proceedingExcelDTO.setDelayFlag(DelayFlag.NOT_DELAY.getStatus());
}else {
proceedingExcelDTO.setDelayFlag(DelayFlag.DELAY.getStatus());
}
if(FilingType.NOT_FILING.getCode().equals(proceeding.getFiling())){
proceedingExcelDTO.setFiling(FilingType.NOT_FILING.getStatus());
}else if(FilingType.READY_FILING.getCode().equals(proceeding.getFiling())){
proceedingExcelDTO.setFiling(FilingType.READY_FILING.getStatus());
}else {
proceedingExcelDTO.setFiling(FilingType.ALREADY_FILING.getStatus());
}
if(CheckStatus.WAIT_AUDIT.getCode().equals(proceeding.getCheckStatus())){
proceedingExcelDTO.setCheckStatus(CheckStatus.WAIT_AUDIT.getStatus());
}else if(CheckStatus.AUDITING.getCode().equals(proceeding.getCheckStatus())){
proceedingExcelDTO.setCheckStatus(CheckStatus.AUDITING.getStatus());
}else if(CheckStatus.REFUSE.getCode().equals(proceeding.getCheckStatus())){
proceedingExcelDTO.setCheckStatus(CheckStatus.REFUSE.getStatus());
}else if(CheckStatus.WAIT_REPORT.getCode().equals(proceeding.getCheckStatus())){
proceedingExcelDTO.setCheckStatus(CheckStatus.WAIT_REPORT.getStatus());
}else if(CheckStatus.REPORTED.getCode().equals(proceeding.getCheckStatus())){
proceedingExcelDTO.setCheckStatus(CheckStatus.REPORTED.getStatus());
}
if(DealEndReportApplyStatus.TO_DO.getCode().equals(proceeding.getEndReportStatus())){
proceedingExcelDTO.setEndReportStatus(DealEndReportApplyStatus.TO_DO.getStatus());
}else if(DealEndReportApplyStatus.DOING.getCode().equals(proceeding.getEndReportStatus())){
proceedingExcelDTO.setEndReportStatus(DealEndReportApplyStatus.DOING.getStatus());
}else if(DealEndReportApplyStatus.DONE.getCode().equals(proceeding.getEndReportStatus())){
proceedingExcelDTO.setEndReportStatus(DealEndReportApplyStatus.DONE.getStatus());
}
proceedingExcelDTO.setFinishTime(sdf.format(proceeding.getFinishTime()));
proceedingExcelDTO.setHandTime(sdf.format(proceeding.getHandTime()));
Map<String, String> namValMap = ExcelUtil.getNamValMap(proceedingExcelDTO, false);
String dynamicData = proceeding.getDynamicData();
Map stringToMap = JSONObject.parseObject(dynamicData);
namValMap.putAll(stringToMap);
maps.add(namValMap);
list.add(proceedingExcelDTO);
}
Proceeding proceeding = proceedings.get(0);
String diyForm = proceeding.getDiyForm();
Map stringToMap = JSONObject.parseObject(diyForm);
String listShowValue = stringToMap.get(“listShowValue”).toString();
List
mapList = JSONObject.parseArray(listShowValue, Map.class);

    return ExcelUtil.exportStream(ExcelUtil.createHSSFWorkbook(maps, createMappingListForBusinessInfo(mapList)), response, "事项表");
}

@Override
public Workbook excelForTable(String data, HttpServletResponse response) {
    return null;
}

private List<ExcelUtil.FieldMapping> createMappingListForBusinessInfo(List<Map> map) {
    List<ExcelUtil.FieldMapping> mappings = new ArrayList<>(14);
    mappings.add(new ExcelUtil.FieldMapping("事项编码", "matterNumber"));
    mappings.add(new ExcelUtil.FieldMapping("是否延期", "delayFlag"));
    mappings.add(new ExcelUtil.FieldMapping("事项来源", "matterSource"));
    mappings.add(new ExcelUtil.FieldMapping("事项名称", "matterName"));
    mappings.add(new ExcelUtil.FieldMapping("完成时限", "finishTime"));
    mappings.add(new ExcelUtil.FieldMapping("进度反馈要求", "progressFeedbackRequirement"));
    mappings.add(new ExcelUtil.FieldMapping("督办处室", "supervisionDepartment"));
    mappings.add(new ExcelUtil.FieldMapping("督办人", "supervisionUser"));
    mappings.add(new ExcelUtil.FieldMapping("督办人联系方式", "supervisionUserPhone"));
    mappings.add(new ExcelUtil.FieldMapping("交办时间", "handTime"));
    mappings.add(new ExcelUtil.FieldMapping("事项办理情况", "proceedingStatus"));
    mappings.add(new ExcelUtil.FieldMapping("事项办理情况步骤", "proceedingStatusStep"));
    mappings.add(new ExcelUtil.FieldMapping("是否已归档 0->否;1->是", "filing"));
    mappings.add(new ExcelUtil.FieldMapping("创建人", "createUser"));
    mappings.add(new ExcelUtil.FieldMapping("创建人账号", "createUserCode"));
    mappings.add(new ExcelUtil.FieldMapping("审核状态", "checkStatus"));
    mappings.add(new ExcelUtil.FieldMapping("办结报告申请状态", "endReportStatus"));
    for (Map m: map) {
        mappings.add(new ExcelUtil.FieldMapping(m.get("label").toString(), m.get("prop").toString()));
    }
    return mappings;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值