Browse Source

立项批复时间

tags/24080901
PoffyZhang 1 year ago
parent
commit
fdb61533e9
4 changed files with 140 additions and 31 deletions
  1. +31
    -29
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java
  2. +11
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java
  3. +63
    -1
      pmapi/src/test/java/com/ningdatech/pmapi/instance/InstanceTest.java
  4. +35
    -0
      pmapi/src/test/java/com/ningdatech/pmapi/stream/stream.java

+ 31
- 29
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java View File

@@ -80,35 +80,37 @@ public class DefaultDeclaredProjectManage {
}

public void checkAmount(ProjectDTO projectInfo) {
BigDecimal declareAmount = projectInfo.getDeclareAmount();
BigDecimal govSuperFinanceAmount = projectInfo.getDeclareGovSuperiorFinanceAmount();
BigDecimal govOwnFinanceAmount = projectInfo.getDeclareGovOwnFinanceAmount();
BigDecimal bankLendingAmount = projectInfo.getDeclareBankLendingAmount();
BigDecimal haveAmount = projectInfo.getDeclareHaveAmount();
BigDecimal otherAmount = projectInfo.getDeclareOtherAmount();
BigDecimal totalAmount = govSuperFinanceAmount
.add(govOwnFinanceAmount).add(bankLendingAmount).add(haveAmount).add(otherAmount);
VUtils.isTrue(declareAmount.compareTo(totalAmount) != 0)
.throwMessage(String.format("申报失败! 申报总金额【%s】 不等于其它申报金额 【%s】",declareAmount,totalAmount));

//判断 年度计划金额 如果开着的话
if(projectInfo.getIsAnnualPlanAmount()){
BigDecimal annualPlanAmount = projectInfo.getAnnualPlanAmount();

VUtils.isTrue(annualPlanAmount.compareTo(BigDecimal.ZERO) <= 0)
.throwMessage(String.format("申报失败! 年度支付总金额【%s】 不能小于等于0",annualPlanAmount));
VUtils.isTrue(annualPlanAmount.compareTo(declareAmount) > 0)
.throwMessage(String.format("申报失败! 年度支付总金额【%s】 不能大于申报金额 【%s】",annualPlanAmount,declareAmount));

BigDecimal annualGovSuperAmount = projectInfo.getAnnualPlanGovSuperiorFinanceAmount();
BigDecimal annualOwnSuperAmount = projectInfo.getAnnualPlanGovOwnFinanceAmount();
BigDecimal annualBankLendingAmount = projectInfo.getAnnualPlanBankLendingAmount();
BigDecimal annualHaveAmount = projectInfo.getAnnualPlanHaveAmount();
BigDecimal anualOtherAmount = projectInfo.getAnnualPlanOtherAmount();
BigDecimal totalAnnual = annualGovSuperAmount
.add(annualOwnSuperAmount).add(annualBankLendingAmount).add(annualHaveAmount).add(anualOtherAmount);
VUtils.isTrue(annualPlanAmount.compareTo(totalAnnual) != 0)
.throwMessage(String.format("申报失败! 年度支付总金额【%s】 不等于其它年度支付金额 【%s】",annualPlanAmount,totalAnnual));
if(Objects.nonNull(projectInfo.getDeclareAmount())){
BigDecimal declareAmount = projectInfo.getDeclareAmount();
BigDecimal govSuperFinanceAmount = projectInfo.getDeclareGovSuperiorFinanceAmount();
BigDecimal govOwnFinanceAmount = projectInfo.getDeclareGovOwnFinanceAmount();
BigDecimal bankLendingAmount = projectInfo.getDeclareBankLendingAmount();
BigDecimal haveAmount = projectInfo.getDeclareHaveAmount();
BigDecimal otherAmount = projectInfo.getDeclareOtherAmount();
BigDecimal totalAmount = govSuperFinanceAmount
.add(govOwnFinanceAmount).add(bankLendingAmount).add(haveAmount).add(otherAmount);
VUtils.isTrue(declareAmount.compareTo(totalAmount) != 0)
.throwMessage(String.format("申报失败! 申报总金额【%s】 不等于其它申报金额 【%s】",declareAmount,totalAmount));

//判断 年度计划金额 如果开着的话
if(projectInfo.getIsAnnualPlanAmount()){
BigDecimal annualPlanAmount = projectInfo.getAnnualPlanAmount();

VUtils.isTrue(annualPlanAmount.compareTo(BigDecimal.ZERO) <= 0)
.throwMessage(String.format("申报失败! 年度支付总金额【%s】 不能小于等于0",annualPlanAmount));
VUtils.isTrue(annualPlanAmount.compareTo(declareAmount) > 0)
.throwMessage(String.format("申报失败! 年度支付总金额【%s】 不能大于申报金额 【%s】",annualPlanAmount,declareAmount));

BigDecimal annualGovSuperAmount = projectInfo.getAnnualPlanGovSuperiorFinanceAmount();
BigDecimal annualOwnSuperAmount = projectInfo.getAnnualPlanGovOwnFinanceAmount();
BigDecimal annualBankLendingAmount = projectInfo.getAnnualPlanBankLendingAmount();
BigDecimal annualHaveAmount = projectInfo.getAnnualPlanHaveAmount();
BigDecimal anualOtherAmount = projectInfo.getAnnualPlanOtherAmount();
BigDecimal totalAnnual = annualGovSuperAmount
.add(annualOwnSuperAmount).add(annualBankLendingAmount).add(annualHaveAmount).add(anualOtherAmount);
VUtils.isTrue(annualPlanAmount.compareTo(totalAnnual) != 0)
.throwMessage(String.format("申报失败! 年度支付总金额【%s】 不等于其它年度支付金额 【%s】",annualPlanAmount,totalAnnual));
}
}
}



+ 11
- 1
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java View File

@@ -11,10 +11,13 @@ import javax.servlet.http.HttpServletResponse;

import com.ningdatech.pmapi.projectdeclared.manage.DeclaredProjectManage;
import com.ningdatech.pmapi.todocenter.handle.WithDrawHandle;
import com.wflow.workflow.enums.ProcessHandlerEnum;
import org.apache.commons.io.FileUtils;
import org.assertj.core.util.Lists;
import org.flowable.engine.HistoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.variable.api.history.HistoricVariableInstance;
import org.springframework.beans.BeanUtils;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Component;
@@ -107,7 +110,7 @@ public class TodoCenterManage {

private final ProcessTaskService processTaskService;
private final HistoryService historyService;
private final IUserInfoService userInfoService;
private final RuntimeService runtimeService;
private final IProjectService projectService;
private final ProjectLibManage projectLibManage;
private final StateMachineUtils stateMachineUtils;
@@ -870,13 +873,20 @@ public class TodoCenterManage {

//项目名称去重
defaultDeclaredProjectManage.checkDuplication(projectDto);
defaultDeclaredProjectManage.checkAmount(projectDto);

//修改项目内容
if(!modifyProject(projectDto)){
throw new BusinessException("调整项目失败!");
}

//设置 节点的状态 为null 代表继续审核
runtimeService.setVariables(dto.getInstanceId(),
org.assertj.core.util.Maps.newHashMap("approve_" + dto.getTaskId(), "PASS"));

// 更新当前流程状态为审核中
processTaskService.updateProInstStatus(dto.getInstanceId());

return dto.getInstanceId();

}


+ 63
- 1
pmapi/src/test/java/com/ningdatech/pmapi/instance/InstanceTest.java View File

@@ -1,16 +1,30 @@
package com.ningdatech.pmapi.instance;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.AppTests;
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst;
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq;
import com.ningdatech.pmapi.projectlib.service.IProjectInstService;
import com.wflow.contants.ProcessConstant;
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto;
import com.wflow.workflow.bean.dto.TodoCenterListReqDTO;
import org.flowable.engine.HistoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.history.HistoricActivityInstance;
import org.flowable.engine.runtime.ActivityInstance;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.service.history.NativeHistoricTaskInstanceQuery;
import org.junit.Test;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.*;
import java.util.stream.Collectors;

/**
* @Classname InstanceTest
@@ -26,6 +40,12 @@ public class InstanceTest extends AppTests {
@Autowired
private HistoryService historyService;

@Autowired
private ProjectLibManage projectLibManage;

@Autowired
private IProjectInstService projectInstService;

@Test
public void test(){
String instanceId = "896fa188-96d8-11ed-9539-e2d4e8f16b2f";
@@ -54,4 +74,46 @@ public class InstanceTest extends AppTests {
.orderByActivityInstanceStartTime().asc().list();
System.out.println(userTask);
}

@Test
public void testTodo(){
String employeeCode = "GE_e9d5c7917acd4eeea04ff2a9454af62e";
// 查出项目库项目
ProjectListReq projectListReq = new ProjectListReq();
List<Project> projects = projectLibManage.projectList(projectListReq);
Map<Long, Project> projectsMap = projects.stream().collect(Collectors.toMap(Project::getId, v -> v));
// 再查出项目关联的流程实例ID
List<Long> projectIdList = projects.stream().map(Project::getId).collect(Collectors.toList());
if (CollUtil.isEmpty(projectIdList)) {
System.out.println("没有项目");
return;
}
List<ProjectInst> projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class)
.in(ProjectInst::getProjectId, projectIdList)
.orderByDesc(ProjectInst::getProjectId));
Map<String, Project> projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId())));
List<String> instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList());

// 查出用户工作流
TodoCenterListReqDTO req = new TodoCenterListReqDTO();
req.setEmployeeCode(employeeCode);
req.setInstCodes(instCodes);

// 自定义sql查询所有已办的任务实例
String nativeSql = "SELECT ht.* FROM act_hi_taskinst ht WHERE assignee_ = '" + employeeCode +
"' and end_time_ is not NULL";
NativeHistoricTaskInstanceQuery taskInstanceQuery =
historyService.createNativeHistoricTaskInstanceQuery().sql(nativeSql);
List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();

Set set = new HashSet();
List<HistoricTaskInstance> taskInstanceList = taskInstances.stream()
.filter(t -> instCodes.contains(t.getProcessInstanceId()))
.sorted(Comparator.comparing(HistoricTaskInstance::getEndTime)).collect(Collectors.toList())
.stream()
.filter(v -> set.add(v.getProcessInstanceId()))
.collect(Collectors.toList());

System.out.println(taskInstanceList.size());
}
}

+ 35
- 0
pmapi/src/test/java/com/ningdatech/pmapi/stream/stream.java View File

@@ -0,0 +1,35 @@
package com.ningdatech.pmapi.stream;

import org.flowable.task.api.history.HistoricTaskInstance;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
* @Classname stream
* @Description
* @Date 2023/4/3 14:52
* @Author PoffyZhang
*/
public class stream {

@Test
public void test(){
List<Integer> list = new ArrayList<>();
list.add(1);
list.add(2);
list.add(2);
list.add(3);
list.add(3);
list.add(1);
list.add(1);
list.add(1);

Set<Integer> set = list.stream().collect(Collectors.toSet());
System.out.println(set);
}

}

Loading…
Cancel
Save