|
|
@@ -1,11 +1,20 @@ |
|
|
|
package com.ningdatech.pmapi.projectlib.manage; |
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.ningdatech.basic.exception.BizException; |
|
|
|
import com.ningdatech.basic.function.VUtils; |
|
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
|
import com.ningdatech.basic.util.CollUtils; |
|
|
|
import com.ningdatech.basic.util.NdDateUtils; |
|
|
|
import com.ningdatech.pmapi.common.constant.CommonConstant; |
|
|
|
import com.ningdatech.pmapi.common.util.ExcelDownUtil; |
|
|
|
import com.ningdatech.pmapi.common.util.ExcelExportStyle; |
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectRenewalApprovalStatusEnum; |
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; |
|
|
|
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.dto.ProjectRenewalExportDTO; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.dto.ProjectRenewalFundDeclarationDTO; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.Project; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.entity.ProjectRenewalFundDeclaration; |
|
|
@@ -20,9 +29,12 @@ import lombok.RequiredArgsConstructor; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.IOException; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* <p> |
|
|
@@ -117,15 +129,78 @@ public class ProjectRenewalFundManage { |
|
|
|
return declaration.getId(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 续建项目审核 |
|
|
|
* @param param |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public Long audit(ProjectRenewalAuditReq param) { |
|
|
|
Long projectRenewalId = param.getProjectRenewalId(); |
|
|
|
ProjectRenewalFundDeclaration projectRenewal = projectRenewalFundDeclarationService.getById(projectRenewalId); |
|
|
|
if (Boolean.TRUE.equals(param.getResult())){ |
|
|
|
projectRenewal.setApprovalStatus(ProjectRenewalApprovalStatusEnum.PASS.name()); |
|
|
|
}else { |
|
|
|
String auditOpinion = param.getAuditOpinion(); |
|
|
|
if (StrUtil.isBlank(auditOpinion)){ |
|
|
|
throw new BizException("审核意见不能为空"); |
|
|
|
} |
|
|
|
projectRenewal.setAuditOpinion(auditOpinion); |
|
|
|
projectRenewal.setApprovalStatus(ProjectRenewalApprovalStatusEnum.NOT_PASS.name()); |
|
|
|
} |
|
|
|
// projectRenewal |
|
|
|
return null; |
|
|
|
projectRenewal.setUpdateOn(LocalDateTime.now()); |
|
|
|
projectRenewalFundDeclarationService.updateById(projectRenewal); |
|
|
|
return projectRenewal.getId(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 续建项目删除 |
|
|
|
* @param projectRenewalId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public Long delete(Long projectRenewalId) { |
|
|
|
ProjectRenewalFundDeclaration projectRenewal = projectRenewalFundDeclarationService.getById(projectRenewalId); |
|
|
|
projectRenewal.setDeleted(true); |
|
|
|
projectRenewal.setUpdateOn(LocalDateTime.now()); |
|
|
|
projectRenewalFundDeclarationService.updateById(projectRenewal); |
|
|
|
return projectRenewal.getId(); |
|
|
|
} |
|
|
|
|
|
|
|
public void exportList(HttpServletResponse response, ProjectRenewalListReq param) { |
|
|
|
|
|
|
|
param.setPageNumber(CommonConstant.EXPORT_PAGE_NUMBER); |
|
|
|
param.setPageSize(CommonConstant.EXPORT_PAGE_SIZE); |
|
|
|
Page<ProjectRenewalFundDeclarationPO> page = param.page(); |
|
|
|
projectRenewalFundDeclarationService.pageSql(page, param); |
|
|
|
List<ProjectRenewalFundDeclarationPO> records = page.getRecords(); |
|
|
|
|
|
|
|
List<ProjectRenewalExportDTO> collect = records.stream().map(r -> { |
|
|
|
ProjectRenewalExportDTO exportDTO = new ProjectRenewalExportDTO(); |
|
|
|
BeanUtils.copyProperties(r, exportDTO); |
|
|
|
exportDTO.setProjectTypeName(ProjectTypeEnum.getDesc(r.getProjectType())); |
|
|
|
if (ProjectRenewalApprovalStatusEnum.PENDING.name().equals(r.getApprovalStatus())) { |
|
|
|
exportDTO.setApprovalStatusName(ProjectRenewalApprovalStatusEnum.PENDING.getDesc()); |
|
|
|
} else if (ProjectRenewalApprovalStatusEnum.PASS.name().equals(r.getApprovalStatus())) { |
|
|
|
exportDTO.setApprovalStatusName(ProjectRenewalApprovalStatusEnum.PASS.getDesc()); |
|
|
|
} else if (ProjectRenewalApprovalStatusEnum.NOT_PASS.name().equals(r.getApprovalStatus())) { |
|
|
|
exportDTO.setApprovalStatusName(ProjectRenewalApprovalStatusEnum.NOT_PASS.getDesc()); |
|
|
|
} |
|
|
|
String createOnStr = NdDateUtils.format(r.getCreateOn(), "yyyy-MM-dd HH:mm"); |
|
|
|
exportDTO.setCreateOn(createOnStr); |
|
|
|
return exportDTO; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
String fileName = "续建项目资金库列表"; |
|
|
|
ExcelDownUtil.setFileName(fileName,response); |
|
|
|
//数据导出处理函数 |
|
|
|
try { |
|
|
|
EasyExcel.write(response.getOutputStream(), ProjectRenewalExportDTO.class) |
|
|
|
.autoCloseStream(false) |
|
|
|
.registerWriteHandler(ExcelExportStyle.formalStyle()) |
|
|
|
.sheet(fileName) |
|
|
|
.doWrite(collect); |
|
|
|
} catch (IOException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |