浏览代码

续建项目资金库审核、删除、导出

master
CMM 1年前
父节点
当前提交
98eae787b3
共有 6 个文件被更改,包括 168 次插入6 次删除
  1. +15
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectRenewalFundDeclarationController.java
  2. +28
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/ProjectRenewalApprovalStatusEnum.java
  3. +77
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectRenewalFundManage.java
  4. +41
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/dto/ProjectRenewalExportDTO.java
  5. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectRenewalFundDeclaration.java
  6. +4
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/req/ProjectRenewalAuditReq.java

+ 15
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectRenewalFundDeclarationController.java 查看文件

@@ -2,6 +2,7 @@ package com.ningdatech.pmapi.projectlib.controller;


import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.common.util.ExcelDownUtil;
import com.ningdatech.pmapi.projectlib.manage.ProjectRenewalFundManage;
import com.ningdatech.pmapi.projectlib.model.dto.ProjectRenewalFundDeclarationDTO;
import com.ningdatech.pmapi.projectlib.model.req.ProjectRenewalAuditReq;
@@ -13,6 +14,8 @@ import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
* <p>
* 续建项目资金申请表 前端控制器
@@ -52,4 +55,16 @@ public class ProjectRenewalFundDeclarationController {
return projectRenewalFundManage.audit(param);
}

@DeleteMapping("/delete/{projectRenewalId}")
@ApiOperation("续建项目删除")
private Long delete(@PathVariable("projectRenewalId") Long projectRenewalId){
return projectRenewalFundManage.delete(projectRenewalId);
}

@GetMapping("/export")
@ApiOperation("续建项目列表导出")
private void exportList(ProjectRenewalListReq req, HttpServletResponse response){
ExcelDownUtil.downXls(response,req,projectRenewalFundManage::exportList);
}

}

+ 28
- 3
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/enumeration/ProjectRenewalApprovalStatusEnum.java 查看文件

@@ -1,6 +1,13 @@
package com.ningdatech.pmapi.projectlib.enumeration;


import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
* <p>
* ProjectRenewalApprovalStatusEnum
@@ -9,6 +16,9 @@ package com.ningdatech.pmapi.projectlib.enumeration;
* @author Poffy
* @since 16:54 2023/2/11
*/
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum ProjectRenewalApprovalStatusEnum {
/**
* 续建项目 审核状态
@@ -16,8 +26,23 @@ public enum ProjectRenewalApprovalStatusEnum {
* 通过
* 不通过
*/
PENDING,
PASS,
NOT_PASS;
PENDING(1,"审核中"),
PASS(2,"通过"),
NOT_PASS(3,"不通过");

private Integer code;
private String desc;

public static String getDescByCode(Integer code) {
if (Objects.isNull(code)) {
return StringUtils.EMPTY;
}
for (ProjectRenewalApprovalStatusEnum t : ProjectRenewalApprovalStatusEnum.values()) {
if (code.equals(t.getCode())) {
return t.desc;
}
}
return StringUtils.EMPTY;
}

}

+ 77
- 2
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectRenewalFundManage.java 查看文件

@@ -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);
}
}
}

+ 41
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/dto/ProjectRenewalExportDTO.java 查看文件

@@ -0,0 +1,41 @@
package com.ningdatech.pmapi.projectlib.model.dto;

import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;

/**
* 项目续建列表导出实体
*
* @author CMM
* @since 2023/02/21 15:03
*/
@Data
public class ProjectRenewalExportDTO implements Serializable {

private static final long serialVersionUID = 1L;

@ExcelProperty("项目名称")
private String projectName;

@ExcelProperty("申报单位")
private String buildOrgName;

@ExcelProperty("项目类型")
private String projectTypeName;

@ExcelProperty("预算年度")
private Integer projectYear;

@ExcelProperty("年度支付金额(万元)")
private BigDecimal annualPaymentAmount;

@ExcelProperty("状态")
private String approvalStatusName;

@ExcelProperty("创建时间")
private String createOn;

}

+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectRenewalFundDeclaration.java 查看文件

@@ -71,5 +71,8 @@ public class ProjectRenewalFundDeclaration implements Serializable {
@ApiModelProperty("是否删除 false未删 true已删")
private Boolean deleted;

@ApiModelProperty("审核意见")
private String auditOpinion;


}

+ 4
- 1
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/req/ProjectRenewalAuditReq.java 查看文件

@@ -3,9 +3,11 @@ package com.ningdatech.pmapi.projectlib.model.req;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
* 续建项目审核请求实体
@@ -17,6 +19,7 @@ import javax.validation.constraints.NotNull;
@ApiModel("续建项目审核请求参数")
public class ProjectRenewalAuditReq {

@NotNull
@ApiModelProperty("续建项目ID")
private Long projectRenewalId;

@@ -25,6 +28,6 @@ public class ProjectRenewalAuditReq {
private Boolean result;

@ApiModelProperty("审核意见")
@Max(200)
@Length(max = 200)
private String auditOpinion;
}

正在加载...
取消
保存