Browse Source

预警 优化 催办

tags/24080901
PoffyZhang 1 year ago
parent
commit
7a7908d003
5 changed files with 231 additions and 32 deletions
  1. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/controller/StatisticsController.java
  2. +96
    -27
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/FundStatisticsManage.java
  3. +15
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/vo/FundStatisticsVO.java
  4. +118
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/EarlyWarningManage.java
  5. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/controller/StatisticsController.java View File

@@ -30,6 +30,6 @@ public class StatisticsController {
@GetMapping("/expert")
@ApiOperation("专家统计")
public ExpertStatisticsVO expert(@RequestParam(required = false) Integer year) {
return fundStatisticsManage.expert(year);
return new ExpertStatisticsVO();
}
}

+ 96
- 27
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/FundStatisticsManage.java View File

@@ -3,10 +3,6 @@ package com.ningdatech.pmapi.dashboard.manage;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.ningdatech.pmapi.common.constant.BizConst;
import com.ningdatech.pmapi.common.statemachine.contants.RegionContant;
import com.ningdatech.pmapi.dashboard.constant.DashboardConstant;
import com.ningdatech.pmapi.dashboard.model.vo.ExpertStatisticsVO;
import com.ningdatech.pmapi.dashboard.model.vo.FundStatisticsVO;
import com.ningdatech.pmapi.gov.model.entity.GovBizProjectApply;
import com.ningdatech.pmapi.gov.model.entity.GovBizProjectApprove;
@@ -19,26 +15,16 @@ import com.ningdatech.pmapi.gov.service.IGovBizProjectProcureService;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.ningdatech.pmapi.sys.model.req.NoticeListReq;
import com.ningdatech.pmapi.todocenter.model.req.ToBeProcessedReq;
import com.ningdatech.pmapi.todocenter.model.vo.TodoCenterStatisticsVO;
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails;
import com.ningdatech.pmapi.user.util.LoginUserUtil;
import com.ningdatech.pmapi.workbench.converter.WorkbenchConverter;
import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ForkJoinPool;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* @Classname FundStatisticsManage
@@ -154,9 +140,23 @@ public class FundStatisticsManage {
}
return Boolean.FALSE;
}).collect(Collectors.toList());
//计划核减
FundStatisticsVO.HeJianAmount planHejian = computePlanHeJian(normalProjects,applies,approves);
//批复核减
FundStatisticsVO.HeJianAmount approvalHejian = computeApprovalHeJian(normalProjects,approves,planHejian.getApproval());
//合同核减
FundStatisticsVO.HeJianAmount contractHejian = computeContractHeJian(normalProjects,procures,approvalHejian.getApproval());

return planHejian.getDiff().add(approvalHejian.getDiff()).add(contractHejian.getDiff());
}

//计算 计划阶段的 核减金额
private FundStatisticsVO.HeJianAmount computePlanHeJian(List<Project> projects, List<GovBizProjectApply> applies,
List<GovBizProjectApprove> approves) {
FundStatisticsVO.HeJianAmount heJianAmount = new FundStatisticsVO.HeJianAmount();

//申报的申报金额(申报项目:初步方案申报金额 项目归集:项目总投资)
BigDecimal declaredAmountApprove = normalProjects.stream().map(p -> {
BigDecimal declaredAmountApprove = projects.stream().map(p -> {
BigDecimal declareAmount = Objects.nonNull(p.getDeclareAmount()) ?
p.getDeclareAmount() : BigDecimal.ZERO;
return declareAmount;
@@ -166,9 +166,10 @@ public class FundStatisticsManage {
return totalAmount;
}).reduce(BigDecimal::add).get();
BigDecimal declaredAmountApproveTotal = declaredAmountApprove.add(declaredAmountApproveGov);
heJianAmount.setApprove(declaredAmountApproveTotal);

//申报的批复金额(申报项目:建设方案申报金额 项目归集:建议总投资)
BigDecimal approvalAmountApprove = normalProjects.stream().map(p -> {
BigDecimal approvalAmountApprove = projects.stream().map(p -> {
BigDecimal declareAmount = Objects.nonNull(p.getApprovalAmount()) ? p.getApprovalAmount() : BigDecimal.ZERO;
return declareAmount;
}).reduce(BigDecimal::add).get();
@@ -177,11 +178,20 @@ public class FundStatisticsManage {
return expertTotalMoney;
}).reduce(BigDecimal::add).get();
BigDecimal approvalAmountApproveTotal = approvalAmountApprove.add(approvalAmountApproveGov);
heJianAmount.setApproval(approvalAmountApproveTotal);
//申报的差额
BigDecimal subtractApprove = declaredAmountApproveTotal.subtract(approvalAmountApproveTotal);
heJianAmount.setDiff(subtractApprove);
return heJianAmount;
}

//计算 批复阶段的 核减金额
private FundStatisticsVO.HeJianAmount computeApprovalHeJian(List<Project> projects,List<GovBizProjectApprove> approves,
BigDecimal approvalAmountApproveTotal){
FundStatisticsVO.HeJianAmount approvalHejian = new FundStatisticsVO.HeJianAmount();
approvalHejian.setApprove(approvalAmountApproveTotal);
//批复的批复金额(申报项目:归集信息建议批复总投资 项目归集:建议批复总投资)
BigDecimal approvalAmountApproval = normalProjects.stream().map(p -> {
BigDecimal approvalAmountApproval = projects.stream().map(p -> {
BigDecimal proposeTotalInvest = Objects.nonNull(p.getProposeTotalInvest()) ? p.getProposeTotalInvest() : BigDecimal.ZERO;
return proposeTotalInvest;
}).reduce(BigDecimal::add).get();
@@ -190,12 +200,20 @@ public class FundStatisticsManage {
return reviewTotalMoney;
}).reduce(BigDecimal::add).get();
BigDecimal approvalAmountApprovalTotal = approvalAmountApproval.add(approvalAmountApprovalGov);
approvalHejian.setApproval(approvalAmountApprovalTotal);
//批复的差额
BigDecimal subtractApproval = approvalAmountApproveTotal.subtract(approvalAmountApprovalTotal);
approvalHejian.setDiff(subtractApproval);
return approvalHejian;
}

//计算 合同阶段的 核减金额
private FundStatisticsVO.HeJianAmount computeContractHeJian(List<Project> projects,List<GovBizProjectProcure> procures,
BigDecimal approvalAmountApprovalTotal){
FundStatisticsVO.HeJianAmount contractHejian = new FundStatisticsVO.HeJianAmount();
contractHejian.setApprove(approvalAmountApprovalTotal);
//合同的批复金额(申报项目:成交金额 项目归集:成交金额)
BigDecimal approvalAmountContract = normalProjects.stream().map(p -> {
BigDecimal approvalAmountContract = projects.stream().map(p -> {
BigDecimal transactionAmount = Objects.nonNull(p.getTransactionAmount()) ? p.getTransactionAmount() : BigDecimal.ZERO;
return transactionAmount;
}).reduce(BigDecimal::add).get();
@@ -205,10 +223,11 @@ public class FundStatisticsManage {
return purchaseAmount;
}).reduce(BigDecimal::add).get();
BigDecimal approvalAmountContractTotal = approvalAmountContract.add(approvalAmountContractGov);
contractHejian.setApproval(approvalAmountContractTotal);
//合同的差额
BigDecimal subtractContract = approvalAmountApprovalTotal.subtract(approvalAmountContractTotal);
return subtractApprove.add(subtractApproval).add(subtractContract);
contractHejian.setDiff(subtractContract);
return contractHejian;
}

/**
@@ -353,15 +372,65 @@ public class FundStatisticsManage {
.map(p -> Objects.nonNull(p.getBaseProjPurchaseAmount()) ? p.getBaseProjPurchaseAmount() : BigDecimal.ZERO)
.reduce(BigDecimal::add).get();
res.setApprovalTotalAmount(contractTotalAmount.add(contractTotalAmountGov));

//计划核减
FundStatisticsVO.HeJianAmount planHejian = computePlanHeJian(projects,applies,approves);
//批复核减
FundStatisticsVO.HeJianAmount approvalHejian = computeApprovalHeJian(projects,approves,planHejian.getApproval());
//合同核减
FundStatisticsVO.HeJianAmount contractHejian = computeContractHeJian(projects,procures,approvalHejian.getApproval());
res.setPlanDeduction(planHejian);
res.setApprovalDeduction(approvalHejian);
res.setContractDeduction(contractHejian);

//部门TOP10
res.setDepartmentTop10(computeTop10(projects,baseInfos,applies,approves,procures));
}

/**
* 专家统计
* @param year
* 计算 部门TOP10
* @param projects
* @param applies
* @param approves
* @param procures
* @return
*/
public ExpertStatisticsVO expert(Integer year) {
ExpertStatisticsVO res = new ExpertStatisticsVO();
private List<FundStatisticsVO.AmountData> computeTop10(List<Project> projects,List<GovBizProjectBaseinfo> baseInfos,
List<GovBizProjectApply> applies, List<GovBizProjectApprove> approves,
List<GovBizProjectProcure> procures) {
//申报项目颗粒度
List<FundStatisticsVO.AmountData> orgAmounts = projects.stream().map(p -> {
FundStatisticsVO.AmountData orgAmount = new FundStatisticsVO.AmountData();
orgAmount.setName(p.getBuildOrgName());
orgAmount.setAmount(completeDeductionAmount(Lists.newArrayList(p),
Collections.emptyList(), Collections.emptyList(),
Collections.emptyList()));
return orgAmount;
}).collect(Collectors.toList());

Map<String, List<GovBizProjectApply>> applyMap = applies.stream().collect(Collectors
.groupingBy(GovBizProjectApply::getBaseProjId));
Map<String, List<GovBizProjectApprove>> approveMap = approves.stream().collect(Collectors
.groupingBy(GovBizProjectApprove::getBaseProjId));
Map<String, List<GovBizProjectProcure>> procureMap = procures.stream().collect(Collectors
.groupingBy(GovBizProjectProcure::getBaseProjId));

//项目归集颗粒度
List<FundStatisticsVO.AmountData> orgAmountsGov = baseInfos.stream().map(p -> {
FundStatisticsVO.AmountData orgAmount = new FundStatisticsVO.AmountData();
orgAmount.setName(p.getBaseBuildDeprt());
List<GovBizProjectApply> appliesThis = applyMap.getOrDefault(p.getBaseProjId(), Collections.emptyList());
List<GovBizProjectApprove> approvesThis = approveMap.getOrDefault(p.getBaseProjId(), Collections.emptyList());
List<GovBizProjectProcure> procuresThis = procureMap.getOrDefault(p.getBaseProjId(), Collections.emptyList());
orgAmount.setAmount(completeDeductionAmount(Collections.emptyList(),
appliesThis, approvesThis,procuresThis));
return orgAmount;
}).collect(Collectors.toList());

//求出TOP10
List<FundStatisticsVO.AmountData> res = Stream.concat(orgAmounts.stream(), orgAmountsGov.stream())
.sorted(Comparator.comparing(FundStatisticsVO.AmountData::getAmount).reversed())
.limit(10).collect(Collectors.toList());

return res;
}


+ 15
- 3
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/vo/FundStatisticsVO.java View File

@@ -32,13 +32,13 @@ public class FundStatisticsVO implements Serializable {
private List<AmountData> threeYearsDeduction;

@ApiModelProperty("计划阶段核减情况")
private List<AmountData> planDeduction;
private HeJianAmount planDeduction;

@ApiModelProperty("批复阶段阶段核减情况")
private List<AmountData> approvalDeduction;
private HeJianAmount approvalDeduction;

@ApiModelProperty("合同阶段阶段核减情况")
private List<AmountData> contractDeduction;
private HeJianAmount contractDeduction;

@ApiModelProperty("各部门核减TOP10")
private List<AmountData> departmentTop10;
@@ -52,4 +52,16 @@ public class FundStatisticsVO implements Serializable {
@ApiModelProperty("名称")
private String name;
}

@Data
public static class HeJianAmount{
@ApiModelProperty("申请金额")
private BigDecimal approve;

@ApiModelProperty("批复金额")
private BigDecimal approval;

@ApiModelProperty("差额")
private BigDecimal diff;
}
}

+ 118
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/EarlyWarningManage.java View File

@@ -168,6 +168,124 @@ public class EarlyWarningManage {
}

/**
* 催办
* @param noticeMethod
* @param noticeContent
* @param adventTimeout
* @param employeeCode
* @param project
*/
public void urging(String noticeMethod,String noticeContent, Integer adventTimeout,Integer overTimeout,
Integer biz, LocalDateTime startTime,String employeeCode,
Project project,Integer ruleType,Integer noticeType,
String path,String batchEmployees,String nodeId) {
//1.存入 预警记录
UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(employeeCode);
WflowEarlyWarningRecords records = new WflowEarlyWarningRecords();
String content = StringUtils.EMPTY;

switch (WarningRuleTypeEnum.checkByCode(ruleType)){
case PROCESS_WARNING:
if(Objects.isNull(noticeType)){
content = convertContent(noticeContent,project.getProjectName(),
InstTypeEnum.getByCode(biz),overTimeout);
}else if(noticeType.equals(WarningNoticeTypeEnum.ADVENT.getCode())) {
content = convertAdventContent(noticeContent,project.getProjectName(),
InstTypeEnum.getByCode(biz),adventTimeout,overTimeout);
}else{
content = convertContent(noticeContent,project.getProjectName(),
InstTypeEnum.getByCode(biz),overTimeout);
}
records.setRuleType(WarningRuleTypeEnum.PROCESS_WARNING.getCode());
break;
case DECLARED_WARNING:
if(Objects.isNull(noticeType)){
content = convertContent(noticeContent,project.getProjectName(),
WarningFlowTypeEnum.getByCode(biz),overTimeout);
}else if(noticeType.equals(WarningNoticeTypeEnum.ADVENT.getCode())) {
content = convertAdventContent(noticeContent,project.getProjectName(),
WarningFlowTypeEnum.getByCode(biz),adventTimeout,overTimeout);
}else{
content = convertContent(noticeContent,project.getProjectName(),
WarningFlowTypeEnum.getByCode(biz),overTimeout);
}
records.setRuleType(WarningRuleTypeEnum.DECLARED_WARNING.getCode());
break;
case OPERATION_WARNING:
if(Objects.isNull(noticeType)){
content = convertContent(noticeContent,project.getProjectName(),
WarningOperationTypeEnum.getByCode(biz),overTimeout);
}else if(noticeType.equals(WarningNoticeTypeEnum.ADVENT.getCode())) {
content = convertAdventContent(noticeContent,project.getProjectName(),
WarningOperationTypeEnum.getByCode(biz),adventTimeout,overTimeout);
}else{
content = convertContent(noticeContent,project.getProjectName(),
WarningOperationTypeEnum.getByCode(biz),overTimeout);
}
records.setRuleType(WarningRuleTypeEnum.OPERATION_WARNING.getCode());
break;
case RENEWAL_FUND:
if(Objects.isNull(noticeType)){
content = convertContent(noticeContent,project.getProjectName(),overTimeout);
}else if(noticeType.equals(WarningNoticeTypeEnum.ADVENT.getCode())) {
content = convertAdventContent(noticeContent,project.getProjectName(),adventTimeout,overTimeout);
}else{
content = convertContent(noticeContent,project.getProjectName(),overTimeout);
}

records.setRuleType(WarningRuleTypeEnum.RENEWAL_FUND.getCode());
break;
default:
log.info("匹配不到 规则类型");
return;
}

records.setAreaCode(project.getAreaCode());
records.setBuildOrgCode(project.getBuildOrgCode());
records.setBuildOrgName(project.getBuildOrgName());
records.setCreateOn(LocalDateTime.now());
records.setWarningTime(LocalDateTime.now());
records.setInstStart(startTime);
records.setInstType(biz);
records.setNoticeMethod(noticeMethod);
records.setNoticeContent(content);
records.setProjectName(project.getProjectName());
records.setWarningUsername(Objects.nonNull(user) ? user.getUsername() : StringUtils.EMPTY);
records.setWarningEmployeecode(employeeCode);
records.setProjectId(project.getId());
records.setProjectCode(project.getProjectCode());
records.setProjectStatus(project.getStatus());
records.setNoticeType(noticeType);
records.setPath(path);
records.setBatchEmployees(batchEmployees);
records.setBiz(biz);
records.setNodeId(nodeId);
earlyWarningRecordsService.save(records);

//2.消息提醒
Notify notify = noticeManage.assemblyAuditNotify(user.getUserId(), project, content);
notify.setType(MsgTypeEnum.PROJECT_REVIEW.name());
notifyService.save(notify);

//3.发短信
if(noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode()))){
SendSmsCmd.SendSmsContext context = new SendSmsCmd.SendSmsContext();
context.setReceiveNumber(user.getMobile());
context.setContent(content);
yxtCallOrSmsHelper.sendSms(context);
}

//4.浙政钉
if(noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode()))){
// 获取发送浙政钉工作通知必要信息
WorkNoticeInfo passWorkNoticeInfo = noticeManage.getSendWorkNoticeInfo(employeeCode);
passWorkNoticeInfo.setMsg(content);
// 放入工作通知暂存表中,通过扫表异步发送
workNoticeStagingService.addByWorkNotice(passWorkNoticeInfo, MsgTypeEnum.PROJECT_REVIEW);
}
}

/**
* 续建项目资金
* @param noticeContent
* @param projectName


+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java View File

@@ -338,7 +338,7 @@ public class WorkbenchManage {
Integer overBetween = overTime - adventBetween.intValue();
Integer times = 0;
for(String employee : employees){
earlyWarningManage.doEarlyWarning(noticeMethod,noticeContent,adventBetween.intValue()
earlyWarningManage.urging(noticeMethod,noticeContent,adventBetween.intValue()
,overBetween,biz,
instStart,employee,project,
ruleType,noticeType,path,batchEmployees,record.getNodeId());


Loading…
Cancel
Save