From ba738aef87b86877bb172efe3f64c885d475a3fe Mon Sep 17 00:00:00 2001 From: WendyYang Date: Wed, 4 Sep 2024 17:52:46 +0800 Subject: [PATCH] =?UTF-8?q?modify:=201.=20=E8=B5=84=E9=87=91=E4=B8=8B?= =?UTF-8?q?=E8=BE=BE=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AmountApprovalController.java | 52 +++++++ .../projectlib/manage/AmountApprovalManage.java | 173 +++++++++++++++++++++ .../hz/pm/api/projectlib/model/dto/ProjectDTO.java | 3 + .../hz/pm/api/projectlib/model/entity/Project.java | 3 + .../api/projectlib/model/req/ProjectListReq.java | 3 + .../model/req/SubmitAmountApprovalReq.java | 35 +++++ .../vo/AmountApprovalProgressStatisticsVO.java | 26 ++++ .../api/projectlib/model/vo/ProjectDetailVO.java | 3 + 8 files changed, 298 insertions(+) create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/AmountApprovalController.java create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AmountApprovalManage.java create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/SubmitAmountApprovalReq.java create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/AmountApprovalProgressStatisticsVO.java diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/AmountApprovalController.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/AmountApprovalController.java new file mode 100644 index 0000000..cb91c79 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/AmountApprovalController.java @@ -0,0 +1,52 @@ +package com.hz.pm.api.projectlib.controller; + +import com.hz.pm.api.projectlib.manage.AmountApprovalManage; +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.ningdatech.basic.model.PageVo; +import com.ningdatech.log.annotation.WebLog; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +/** + *

+ * AmountApprovalController + *

+ * + * @author WendyYang + * @since 17:08 2024/9/4 + */ +@Api(tags = "资金下达控制器") +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/amountApproval") +public class AmountApprovalController { + + private final AmountApprovalManage amountApprovalManage; + + @GetMapping("/page") + @ApiOperation("分页查询") + public PageVo page(ProjectListReq req) { + return amountApprovalManage.page(req); + } + + @GetMapping("progressStatistics") + @ApiOperation("资金下达进度统计") + public AmountApprovalProgressStatisticsVO progressStatistics(ProjectListReq req) { + return amountApprovalManage.progressStatistics(req); + } + + @PostMapping("/submit") + @ApiOperation("资金下达") + @WebLog("资金下达") + public void submit(@RequestBody @Valid SubmitAmountApprovalReq req) { + amountApprovalManage.submitAmountApproval(req); + } + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AmountApprovalManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AmountApprovalManage.java new file mode 100644 index 0000000..4256902 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/AmountApprovalManage.java @@ -0,0 +1,173 @@ +package com.hz.pm.api.projectlib.manage; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.NumberUtil; +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.helper.UserInfoHelper; +import com.hz.pm.api.datascope.model.DataScopeDTO; +import com.hz.pm.api.datascope.utils.DataScopeUtil; +import com.hz.pm.api.projectlib.helper.ProjectManageUtil; +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.AnnualPlanListItemVO; +import com.hz.pm.api.projectlib.model.vo.AnnualPlanProgressStatisticsVO; +import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; +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; +import com.hz.pm.api.user.util.LoginUserUtil; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.basic.util.CollUtils; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Optional; + +/** + *

+ * AmountApprovalManage + *

+ * + * @author WendyYang + * @since 17:10 2024/9/4 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class AmountApprovalManage { + + private final IProjectService projectService; + private final UserInfoHelper userInfoHelper; + private final MhUnitCache mhUnitCache; + + + private boolean projectQueryPermission(LambdaQueryWrapper query, UserFullInfoDTO user) { + boolean queryState = true; + Optional currDs = DataScopeUtil.getCurrentUserDataScopeHasUserId(user); + if (!currDs.isPresent()) { + log.warn("没有取到权限信息 当前查询 没有权限条件"); + queryState = false; + } else { + switch (currDs.get().getRole()) { + case NORMAL_MEMBER: + //普通用户 只能看到自己单位去申报的 + query.eq(Project::getBuildOrgCode, user.getMhUnitIdStr()); + break; + case COMPANY_MANAGER: + List childUnitIds = mhUnitCache.getViewChildIdsRecursion(user.getMhUnitId()); + List viewUnitIdList = CollUtils.convert(childUnitIds, String::valueOf); + //单位管理员 看到自己单位去申报的 + 待预审的主管单位是自己单位的项目 + query.and(q1 -> q1.in(Project::getBuildOrgCode, viewUnitIdList) + .or(q2 -> q2.eq(Project::getStage, ProjectStatus.NOT_APPROVED.getCode()) + .in(Project::getSuperOrgCode, viewUnitIdList))); + break; + case SUPER_ADMIN: + //超级管理员 看到丽水全市的 并且也要判断他 同时是不是单位管理员 + break; + case VISITOR: + //访客可以看全市的 + break; + case DASHBOARD: + break; + default: + //没有权限的话 就让它查不到 + queryState = false; + break; + } + } + return queryState; + } + + public PageVo page(ProjectListReq req) { + LambdaQueryWrapper query = ProjectManageUtil.initQuery(); + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); + if (!projectQueryPermission(query, user)) { + return PageVo.empty(); + } + ProjectManageUtil.projectQuery(query, req); + ProjectManageUtil.projectBaseQuery(query); + query.eq(Project::getNewest, Boolean.TRUE) + .ne(Project::getStage, ProjectStatus.STOPPED.getCode()); + if (req.getIsAmountApproval() != null) { + if (Boolean.TRUE.equals(req.getIsAmountApproval())) { + query.gt(Project::getApprovalAmount, 0) + .isNotNull(Project::getApprovalAmount); + } else { + query.and(q -> q.isNull(Project::getApprovalAmount) + .or(q1 -> q1.le(Project::getApprovalAmount, 0))); + } + } + Page page = projectService.page(req.page(), query); + long total = page.getTotal(); + if (total == 0) { + return PageVo.empty(); + } + List records = CollUtils.convert(page.getRecords(), w -> { + ProjectLibListItemVO item = new ProjectLibListItemVO(); + item.setId(w.getId()); + item.setProjectCode(w.getProjectCode()); + item.setProjectName(w.getProjectName()); + item.setStage(w.getStage()); + item.setStatus(w.getStatus()); + item.setProjectYear(w.getProjectYear()); + item.setProjectType(w.getProjectType()); + item.setDeclaredAmount(w.getDeclareAmount()); + item.setBuildOrg(w.getBuildOrgName()); + item.setCreateOn(w.getCreateOn()); + item.setApprovedAmount(w.getApprovalAmount()); + item.setReviewAmount(w.getReviewAmount()); + return item; + }); + return PageVo.of(records, total); + } + + public AmountApprovalProgressStatisticsVO progressStatistics(ProjectListReq req) { + LambdaQueryWrapper query = ProjectManageUtil.initQuery(); + UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); + if (!projectQueryPermission(query, user)) { + return null; + } + ProjectManageUtil.projectQuery(query, req); + ProjectManageUtil.projectBaseQuery(query); + query.eq(Project::getNewest, Boolean.TRUE) + .ne(Project::getStage, ProjectStatus.STOPPED.getCode()); + if (req.getIsAmountApproval() != null) { + if (Boolean.TRUE.equals(req.getIsAmountApproval())) { + query.gt(Project::getApprovalAmount, 0) + .isNotNull(Project::getApprovalAmount); + } else { + query.and(q -> q.isNull(Project::getApprovalAmount) + .or(q1 -> q1.le(Project::getApprovalAmount, 0))); + } + } + List page = projectService.list(query); + AmountApprovalProgressStatisticsVO stat = new AmountApprovalProgressStatisticsVO(); + stat.setTotalCount(page.size()); + stat.setApprovalCount(CollUtil.count(page, w -> w.getApprovalAmount() != null + && NumberUtil.isGreater(w.getApprovalAmount(), BigDecimal.ZERO))); + stat.setUnApprovalCount(stat.getTotalCount() - stat.getApprovalCount()); + return stat; + } + + public void submitAmountApproval(SubmitAmountApprovalReq req) { + Project project = projectService.getNewestNoNull(req.getProjectId()); + Assert.isTrue(ProjectStatus.STOPPED.eq(project.getStage()), "项目终止中"); + LambdaUpdateWrapper wrapper = Wrappers.lambdaUpdate(Project.class) + .set(Project::getApprovalAmountFile, req.getApprovalAmountFile()) + .set(Project::getApprovalAmount, req.getApprovalAmount()) + .set(Project::getReviewAmount, req.getReviewAmount()) + .eq(Project::getId, project.getId()); + projectService.update(wrapper); + } + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/ProjectDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/ProjectDTO.java index af072d2..31bdcd2 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/ProjectDTO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/ProjectDTO.java @@ -183,6 +183,9 @@ public class ProjectDTO implements Serializable { @ApiModelProperty("年度支付计划") private List paymentPlanList; + @ApiModelProperty("资金下达附件") + private String approvalAmountFile; + @ApiModelProperty("立项批复资金(万元)") private BigDecimal approvalAmount; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/Project.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/Project.java index d5cf841..b14532e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/Project.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/Project.java @@ -185,6 +185,9 @@ public class Project implements Serializable { //================================================================================================================== + @ApiModelProperty("资金下达附件") + private String approvalAmountFile; + @ApiModelProperty("批复-自有金额(万元)") private BigDecimal approvalHaveAmount; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/ProjectListReq.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/ProjectListReq.java index 82f54cc..807967a 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/ProjectListReq.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/ProjectListReq.java @@ -121,6 +121,9 @@ public class ProjectListReq extends PagePo { private Boolean isStartDeclaredProject; + @ApiModelProperty("是否资金已下达") + private Boolean isAmountApproval; + private Long declaredUnitId; private List declaredUnitIds; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/SubmitAmountApprovalReq.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/SubmitAmountApprovalReq.java new file mode 100644 index 0000000..6f924c7 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/SubmitAmountApprovalReq.java @@ -0,0 +1,35 @@ +package com.hz.pm.api.projectlib.model.req; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; + +/** + *

+ * SubmitAmountApprovalReq + *

+ * + * @author WendyYang + * @since 17:28 2024/9/4 + */ +@Data +public class SubmitAmountApprovalReq { + + @ApiModelProperty("项目ID") + @NotNull(message = "项目ID不能为空") + private Long projectId; + + @ApiModelProperty("批复金额") + @NotNull(message = "批复金额不能为空") + private BigDecimal approvalAmount; + + @ApiModelProperty("评审金额") + @NotNull(message = "评审金额不能为空") + private BigDecimal reviewAmount; + + @ApiModelProperty("资金下达附件") + private String approvalAmountFile; + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/AmountApprovalProgressStatisticsVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/AmountApprovalProgressStatisticsVO.java new file mode 100644 index 0000000..a750a8d --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/AmountApprovalProgressStatisticsVO.java @@ -0,0 +1,26 @@ +package com.hz.pm.api.projectlib.model.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + *

+ * AmountApprovalProgressStatisticsVO + *

+ * + * @author WendyYang + * @since 17:01 2024/9/4 + */ +@Data +public class AmountApprovalProgressStatisticsVO { + + @ApiModelProperty("总数量") + private Integer totalCount; + + @ApiModelProperty("已下达资金数量") + private Integer approvalCount; + + @ApiModelProperty("未下达资金数量") + private Integer unApprovalCount; + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectDetailVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectDetailVO.java index b415ccc..6c8cfa8 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectDetailVO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectDetailVO.java @@ -213,6 +213,9 @@ public class ProjectDetailVO { @ApiModelProperty("年度支付计划-其它资金(万元)") private BigDecimal annualPlanOtherAmount; + @ApiModelProperty("资金下达附件") + private String approvalAmountFile; + @ApiModelProperty("立项批复资金(万元)") private BigDecimal approvalAmount;