Browse Source

modify:

1. 下达资金修改;
tags/24101601
WendyYang 3 months ago
parent
commit
ec8040c76d
12 changed files with 255 additions and 8 deletions
  1. +1
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/DecimalUtil.java
  2. +15
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/AmountApprovalController.java
  3. +48
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/entity/ProjectApprovalAmount.java
  4. +70
    -5
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AmountApprovalManage.java
  5. +8
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java
  6. +16
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/NdProjectApprovalAmountMapper.java
  7. +5
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/NdProjectApprovalAmountMapper.xml
  8. +31
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/ProjectApprovalAmountDTO.java
  9. +1
    -2
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/SubmitAmountApprovalReq.java
  10. +4
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectDetailVO.java
  11. +36
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/INdProjectApprovalAmountService.java
  12. +20
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/impl/NdProjectApprovalAmountServiceImpl.java

+ 1
- 1
hz-pm-api/src/main/java/com/hz/pm/api/common/util/DecimalUtil.java View File

@@ -24,7 +24,7 @@ public class DecimalUtil {
private DecimalUtil() {
}

public static boolean notNullAndGtZero(BigDecimal num) {
public static boolean noNullAndGtZero(BigDecimal num) {
return num != null && num.compareTo(BigDecimal.ZERO) > 0;
}



+ 15
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/AmountApprovalController.java View File

@@ -1,6 +1,7 @@
package com.hz.pm.api.projectlib.controller;

import com.hz.pm.api.projectlib.manage.AmountApprovalManage;
import com.hz.pm.api.projectlib.model.dto.ProjectApprovalAmountDTO;
import com.hz.pm.api.projectlib.model.req.ProjectListReq;
import com.hz.pm.api.projectlib.model.req.SubmitAmountApprovalReq;
import com.hz.pm.api.projectlib.model.vo.AmountApprovalProgressStatisticsVO;
@@ -10,9 +11,11 @@ import com.ningdatech.log.annotation.WebLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
* <p>
@@ -49,4 +52,16 @@ public class AmountApprovalController {
amountApprovalManage.submitAmountApproval(req);
}

@PostMapping("/initOldApprovalAmount")
@PreAuthorize("hasAuthority('SUPER_ADMIN')")
public void initOldApprovalAmount() {
amountApprovalManage.initOldApprovalAmount();
}

@GetMapping("/{projectCode}")
@ApiOperation("查询项目资金下达记录")
public List<ProjectApprovalAmountDTO> listApprovalAmounts(@PathVariable String projectCode) {
return amountApprovalManage.listApprovalAmounts(projectCode);
}

}

+ 48
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/entity/ProjectApprovalAmount.java View File

@@ -0,0 +1,48 @@
package com.hz.pm.api.projectlib.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

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

/**
* <p>
* 项目资金下达记录
* </p>
*
* @author WendyYang
* @since 2024-10-09
*/
@Data
@TableName("ND_PROJECT_APPROVAL_AMOUNT")
@ApiModel(value = "NdProjectApprovalAmount对象")
public class ProjectApprovalAmount implements Serializable {

private static final long serialVersionUID = 1L;

@TableId(value = "ID", type = IdType.AUTO)
private Long id;

@ApiModelProperty("下达资金")
private BigDecimal approvalAmount;

@ApiModelProperty("年度")
private Integer approvalYear;

@ApiModelProperty("项目ID")
private Long projectId;

@ApiModelProperty("项目编号")
private String projectCode;

@TableField(fill = FieldFill.INSERT_UPDATE)
private Long createBy;

@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime createOn;

}

+ 70
- 5
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AmountApprovalManage.java View File

@@ -1,23 +1,32 @@
package com.hz.pm.api.projectlib.manage;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hz.pm.api.common.exception.ReturnException;
import com.hz.pm.api.common.helper.UserInfoHelper;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.util.DecimalUtil;
import com.hz.pm.api.datascope.model.DataScopeDTO;
import com.hz.pm.api.datascope.utils.DataScopeUtil;
import com.hz.pm.api.external.model.enumeration.MhUnitStripEnum;
import com.hz.pm.api.projectlib.entity.ProjectApprovalAmount;
import com.hz.pm.api.projectlib.helper.ProjectManageUtil;
import com.hz.pm.api.projectlib.model.dto.ProjectApprovalAmountDTO;
import com.hz.pm.api.projectlib.model.entity.Project;
import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus;
import com.hz.pm.api.projectlib.model.req.ProjectListReq;
import com.hz.pm.api.projectlib.model.req.SubmitAmountApprovalReq;
import com.hz.pm.api.projectlib.model.vo.AmountApprovalProgressStatisticsVO;
import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO;
import com.hz.pm.api.projectlib.service.INdProjectApprovalAmountService;
import com.hz.pm.api.projectlib.service.IProjectService;
import com.hz.pm.api.user.helper.MhUnitCache;
import com.hz.pm.api.user.security.model.UserFullInfoDTO;
@@ -26,11 +35,15 @@ import com.ningdatech.basic.model.PageVo;
import com.ningdatech.basic.util.CollUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.assertj.core.error.ElementsShouldBeExactly;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
* <p>
@@ -45,6 +58,7 @@ import java.util.Optional;
@RequiredArgsConstructor
public class AmountApprovalManage {

private final INdProjectApprovalAmountService projectApprovalAmountService;
private final IProjectService projectService;
private final UserInfoHelper userInfoHelper;
private final MhUnitCache mhUnitCache;
@@ -150,25 +164,76 @@ public class AmountApprovalManage {
List<Project> page = projectService.list(query);
AmountApprovalProgressStatisticsVO stat = new AmountApprovalProgressStatisticsVO();
stat.setTotalCount(page.size());
stat.setApprovalCount(CollUtil.count(page, w -> DecimalUtil.notNullAndGtZero(w.getApprovalAmount())));
stat.setApprovalCount(CollUtil.count(page, w -> DecimalUtil.noNullAndGtZero(w.getApprovalAmount())));
stat.setUnApprovalCount(stat.getTotalCount() - stat.getApprovalCount());
return stat;
}

public void submitAmountApproval(SubmitAmountApprovalReq req) {
public synchronized void submitAmountApproval(SubmitAmountApprovalReq req) {
Project project = projectService.getNewestNoNull(req.getProjectId());
if (ProjectStatus.STOPPED.eq(project.getStage())
|| ProjectStatus.CHANGE.eq(project.getStage())) {
throw ReturnException.wrap("暂不允许下达资金");
}
BigDecimal totalApprovalAmount = ObjUtil.defaultIfNull(project.getApprovalAmount(), BigDecimal.ZERO);
boolean approved = DecimalUtil.noNullAndGtZero(totalApprovalAmount);
if (!approved && req.getReviewAmount() == null) {
throw ReturnException.wrap("评审总投资不能为空");
}
BigDecimal currTotalApprovalAmount = NumberUtil.add(totalApprovalAmount, req.getApprovalAmount());
if (approved && NumberUtil.isGreater(currTotalApprovalAmount, project.getReviewAmount())) {
throw ReturnException.wrap("暂不允许下达资金");
}
Wrapper<Project> wrapper = Wrappers.lambdaUpdate(Project.class)
.set(Project::getApprovalAmountFile, req.getApprovalAmountFile())
.set(Project::getApprovalAmount, req.getApprovalAmount())
.set(Project::getReviewAmount, req.getReviewAmount())
.set(StrUtil.isNotBlank(req.getApprovalAmountFile()), Project::getApprovalAmountFile, req.getApprovalAmountFile())
.set(Project::getApprovalAmount, currTotalApprovalAmount)
.set(req.getReviewAmount() != null, Project::getReviewAmount, req.getReviewAmount())
.set(Project::getUpdateOn, LocalDateTime.now())
.set(Project::getUpdateBy, LoginUserUtil.getUserId())
.eq(Project::getId, project.getId());

Integer currProjectYear = getLastApprovalYear(project);
ProjectApprovalAmount projectApprovalAmount = new ProjectApprovalAmount();
projectApprovalAmount.setApprovalYear(currProjectYear);
projectApprovalAmount.setApprovalAmount(req.getApprovalAmount());
projectApprovalAmount.setProjectId(project.getId());
projectApprovalAmount.setProjectCode(project.getProjectCode());
projectApprovalAmountService.save(projectApprovalAmount);
projectService.update(wrapper);
}

private Integer getLastApprovalYear(Project project) {
ProjectApprovalAmount lastApprovalAmount = projectApprovalAmountService.getByProjectCode(project.getProjectCode());
Integer currProjectYear;
if (lastApprovalAmount == null) {
currProjectYear = project.getProjectYear();
} else {
currProjectYear = lastApprovalAmount.getApprovalYear() + 1;
}
return currProjectYear;
}

@Transactional(rollbackFor = Exception.class)
public synchronized void initOldApprovalAmount(){
LambdaQueryWrapper<Project> query = Wrappers.lambdaQuery(Project.class)
.gt(Project::getApprovalAmount, 0)
.isNotNull(Project::getApprovalAmount)
.eq(Project::getNewest, Boolean.TRUE);
List<Project> projects = projectService.list(query);
List<ProjectApprovalAmount> approvalAmounts = projects.stream().map(w -> {
ProjectApprovalAmount approvalAmount = new ProjectApprovalAmount();
approvalAmount.setApprovalYear(w.getProjectYear());
approvalAmount.setApprovalAmount(w.getApprovalAmount());
approvalAmount.setProjectId(w.getId());
approvalAmount.setProjectCode(w.getProjectCode());
return approvalAmount;
}).collect(Collectors.toList());
projectApprovalAmountService.saveBatch(approvalAmounts);
}

public List<ProjectApprovalAmountDTO> listApprovalAmounts(String projectCode){
List<ProjectApprovalAmount> approvalAmounts = projectApprovalAmountService.listByProjectCode(projectCode);
return BeanUtil.copyToList(approvalAmounts, ProjectApprovalAmountDTO.class);
}

}

+ 8
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java View File

@@ -24,6 +24,7 @@ import com.hz.pm.api.common.model.constant.ExistsSqlConst;
import com.hz.pm.api.common.model.entity.ExcelExportWriter;
import com.hz.pm.api.common.statemachine.util.ProjectStateMachineUtil;
import com.hz.pm.api.common.util.BizUtils;
import com.hz.pm.api.common.util.DecimalUtil;
import com.hz.pm.api.common.util.ExcelDownUtil;
import com.hz.pm.api.common.util.StrUtils;
import com.hz.pm.api.datascope.model.DataScopeDTO;
@@ -56,12 +57,14 @@ import com.hz.pm.api.projectdeclared.service.IPreInsAcceptancePersonService;
import com.hz.pm.api.projectdeclared.service.IPurchaseService;
import com.hz.pm.api.projectdeclared.utils.ProjectCodeGenUtil;
import com.hz.pm.api.projectdeclared.utils.ProjectIdCodeCacheUtil;
import com.hz.pm.api.projectlib.entity.ProjectApprovalAmount;
import com.hz.pm.api.projectlib.entity.ProjectGovSystemReplaceInfos;
import com.hz.pm.api.projectlib.handle.ProcessProgressHelper;
import com.hz.pm.api.projectlib.helper.ProjectManageUtil;
import com.hz.pm.api.projectlib.helper.ProjectSaveHelper;
import com.hz.pm.api.projectlib.model.constant.ProjectConstant;
import com.hz.pm.api.projectlib.model.dto.GovSystemReplaceInfoDTO;
import com.hz.pm.api.projectlib.model.dto.ProjectApprovalAmountDTO;
import com.hz.pm.api.projectlib.model.dto.ProjectDTO;
import com.hz.pm.api.projectlib.model.dto.ProjectPaymentPlanDTO;
import com.hz.pm.api.projectlib.model.entity.*;
@@ -147,6 +150,7 @@ public class ProjectLibManage {
private final IMhProjectService mhProjectService;
private final ProjectReviewManage projectReviewManage;
private final IMeetingInnerProjectService meetingInnerProjectService;
private final INdProjectApprovalAmountService projectApprovalAmountService;

public PageVo<ProjectLibListItemVO> projectLibList(ProjectListReq req) {
LambdaQueryWrapper<Project> query = ProjectManageUtil.projectQuery(req);
@@ -704,6 +708,10 @@ public class ProjectLibManage {
BeanUtils.copyProperties(project, retProjectDetail);
retProjectDetail.buildDynamicForm(project.getDynamicForm());
String projectCode = project.getProjectCode();
if (DecimalUtil.noNullAndGtZero(project.getApprovalAmount())) {
List<ProjectApprovalAmount> approvalAmounts = projectApprovalAmountService.listByProjectCode(projectCode);
retProjectDetail.setApprovalAmounts(BeanUtil.copyToList(approvalAmounts, ProjectApprovalAmountDTO.class));
}
// 查询应用
List<ProjectApplication> applications = applicationService.list(projectCode, project.getVersion(), project.getIsConstruct());



+ 16
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/NdProjectApprovalAmountMapper.java View File

@@ -0,0 +1,16 @@
package com.hz.pm.api.projectlib.mapper;

import com.hz.pm.api.projectlib.entity.ProjectApprovalAmount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
* <p>
* Mapper 接口
* </p>
*
* @author WendyYang
* @since 2024-10-09
*/
public interface NdProjectApprovalAmountMapper extends BaseMapper<ProjectApprovalAmount> {

}

+ 5
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/mapper/NdProjectApprovalAmountMapper.xml View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hz.pm.api.projectlib.mapper.NdProjectApprovalAmountMapper">

</mapper>

+ 31
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/ProjectApprovalAmountDTO.java View File

@@ -0,0 +1,31 @@
package com.hz.pm.api.projectlib.model.dto;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
* <p>
* 项目资金下达记录
* </p>
*
* @author WendyYang
* @since 2024-10-09
*/
@Data
public class ProjectApprovalAmountDTO {


@ApiModelProperty("下达资金")
private BigDecimal approvalAmount;

@ApiModelProperty("年度")
private Integer approvalYear;

private LocalDateTime createOn;

}

+ 1
- 2
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/SubmitAmountApprovalReq.java View File

@@ -25,8 +25,7 @@ public class SubmitAmountApprovalReq {
@NotNull(message = "批复金额不能为空")
private BigDecimal approvalAmount;

@ApiModelProperty("评审金额")
@NotNull(message = "评审金额不能为空")
@ApiModelProperty("评审总投资")
private BigDecimal reviewAmount;

@ApiModelProperty("资金下达附件")


+ 4
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectDetailVO.java View File

@@ -8,6 +8,7 @@ import com.hz.pm.api.meeting.entity.dto.ProjectReviewResultDTO;
import com.hz.pm.api.portrait.model.vo.TagVO;
import com.hz.pm.api.projectdeclared.model.vo.PurchaseFullInfoVO;
import com.hz.pm.api.projectlib.model.dto.GovSystemReplaceInfoDTO;
import com.hz.pm.api.projectlib.model.dto.ProjectApprovalAmountDTO;
import com.hz.pm.api.projectlib.model.dto.ProjectPaymentPlanDTO;
import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum;
import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus;
@@ -594,4 +595,7 @@ public class ProjectDetailVO {
@ApiModelProperty("所属领域")
private Integer unitStrip;

@ApiModelProperty("资金下达情况")
private List<ProjectApprovalAmountDTO> approvalAmounts;

}

+ 36
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/INdProjectApprovalAmountService.java View File

@@ -0,0 +1,36 @@
package com.hz.pm.api.projectlib.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.projectlib.entity.ProjectApprovalAmount;

import java.util.List;

/**
* <p>
* 服务类
* </p>
*
* @author WendyYang
* @since 2024-10-09
*/
public interface INdProjectApprovalAmountService extends IService<ProjectApprovalAmount> {

default ProjectApprovalAmount getByProjectCode(String projectCode) {
Wrapper<ProjectApprovalAmount> query = Wrappers.lambdaQuery(ProjectApprovalAmount.class)
.eq(ProjectApprovalAmount::getProjectCode, projectCode)
.orderByDesc(ProjectApprovalAmount::getApprovalYear)
.last(BizConst.LIMIT_1);
return getOne(query);
}

default List<ProjectApprovalAmount> listByProjectCode(String projectCode) {
Wrapper<ProjectApprovalAmount> query = Wrappers.lambdaQuery(ProjectApprovalAmount.class)
.eq(ProjectApprovalAmount::getProjectCode, projectCode)
.orderByAsc(ProjectApprovalAmount::getApprovalYear);
return list(query);
}

}

+ 20
- 0
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/service/impl/NdProjectApprovalAmountServiceImpl.java View File

@@ -0,0 +1,20 @@
package com.hz.pm.api.projectlib.service.impl;

import com.hz.pm.api.projectlib.entity.ProjectApprovalAmount;
import com.hz.pm.api.projectlib.mapper.NdProjectApprovalAmountMapper;
import com.hz.pm.api.projectlib.service.INdProjectApprovalAmountService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
* <p>
* 服务实现类
* </p>
*
* @author WendyYang
* @since 2024-10-09
*/
@Service
public class NdProjectApprovalAmountServiceImpl extends ServiceImpl<NdProjectApprovalAmountMapper, ProjectApprovalAmount> implements INdProjectApprovalAmountService {

}

Loading…
Cancel
Save