|
|
@@ -1,11 +1,12 @@ |
|
|
|
package com.ningdatech.pmapi.projectdeclared.manage; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.lang.Assert; |
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.ningdatech.basic.exception.BizException; |
|
|
|
import com.ningdatech.basic.function.VUtils; |
|
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
@@ -43,7 +44,6 @@ import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Classname PurchaseManage |
|
|
@@ -115,24 +115,22 @@ public class PurchaseManage { |
|
|
|
query.eq(Project::getNewest, Boolean.TRUE); |
|
|
|
query.orderByAsc(Project::getApprovalDate); |
|
|
|
List<Project> records = projectService.list(query); |
|
|
|
|
|
|
|
AtomicInteger serialNumber = new AtomicInteger(0); |
|
|
|
Assert.notEmpty(records, "暂无数据可导出"); |
|
|
|
List<DeclaredProjectExportDTO> data = Lists.newArrayList(); |
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(records)) { |
|
|
|
data = records.stream().map(r -> { |
|
|
|
DeclaredProjectExportDTO exportDTO = new DeclaredProjectExportDTO(); |
|
|
|
BeanUtils.copyProperties(r, exportDTO); |
|
|
|
exportDTO.setProjectTypeName(ProjectTypeEnum.getDesc(r.getProjectType())); |
|
|
|
exportDTO.setStatusName(ProjectStatusEnum.getDesc(r.getStatus())); |
|
|
|
String createOnStr = NdDateUtils.format(r.getCreateOn(), "yyyy-MM-dd HH:mm"); |
|
|
|
exportDTO.setCreateOn(createOnStr); |
|
|
|
exportDTO.setSerialNumber(serialNumber.incrementAndGet()); |
|
|
|
exportDTO.setApprovedAmount(r.getApprovalAmount()); |
|
|
|
exportDTO.setApprovalDate(r.getApprovalDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
|
|
|
return exportDTO; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
AtomicInteger serialNumber = new AtomicInteger(0); |
|
|
|
records.forEach(r -> { |
|
|
|
DeclaredProjectExportDTO dpe = new DeclaredProjectExportDTO(); |
|
|
|
BeanUtils.copyProperties(r, dpe); |
|
|
|
dpe.setProjectTypeName(ProjectTypeEnum.getDesc(r.getProjectType())); |
|
|
|
dpe.setStatusName(ProjectStatusEnum.getDesc(r.getStatus())); |
|
|
|
String createOnStr = NdDateUtils.format(r.getCreateOn(), "yyyy-MM-dd HH:mm"); |
|
|
|
dpe.setCreateOn(createOnStr); |
|
|
|
dpe.setSerialNumber(serialNumber.incrementAndGet()); |
|
|
|
dpe.setApprovedAmount(r.getApprovalAmount()); |
|
|
|
dpe.setApprovalDate(r.getApprovalDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
|
|
|
data.add(dpe); |
|
|
|
}); |
|
|
|
|
|
|
|
String fileName = "采购结果待备案项目列表"; |
|
|
|
ExcelDownUtil.setFileName(fileName, response); |
|
|
@@ -144,7 +142,8 @@ public class PurchaseManage { |
|
|
|
.sheet(fileName) |
|
|
|
.doWrite(data); |
|
|
|
} catch (IOException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
log.error("导出异常", e); |
|
|
|
throw BizException.wrap("导出失败,请重试"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|