Browse Source

Merge remote-tracking branch 'origin/master'

tags/24080901
WendyYang 1 year ago
parent
commit
31ac4fd6da
5 changed files with 172 additions and 34 deletions
  1. +31
    -29
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java
  2. +6
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/handle/WithDrawHandle.java
  3. +23
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java
  4. +77
    -1
      pmapi/src/test/java/com/ningdatech/pmapi/instance/InstanceTest.java
  5. +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));
}
}
}



+ 6
- 2
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/handle/WithDrawHandle.java View File

@@ -7,6 +7,7 @@ import com.ningdatech.pmapi.todocenter.constant.TodoCenterContant;
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO;
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails;
import com.ningdatech.pmapi.user.util.LoginUserUtil;
import com.wflow.contants.HisProInsEndActId;
import com.wflow.workflow.bean.dto.ReqProcessHandlerDTO;
import com.wflow.workflow.bean.process.ProgressNode;
import com.wflow.workflow.bean.process.enums.NodeTypeEnum;
@@ -23,6 +24,7 @@ import org.springframework.stereotype.Component;

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

/**
* @Classname WithDrawHandle
@@ -212,9 +214,11 @@ public class WithDrawHandle {
.processInstanceId(instance.getId()).finished()
.activityType(TodoCenterContant.Handler.ACTIVITY_APPROVAL)
.orderByHistoricActivityInstanceEndTime().asc().list();

List<HistoricActivityInstance> instances = finished.stream()
.filter(a -> !HisProInsEndActId.WITHDRAW.equals(a.getDeleteReason()))
.collect(Collectors.toList());
//如果有已经被审核过的 节点 返回false
if(CollUtil.isNotEmpty(finished)){
if(CollUtil.isNotEmpty(instances)){
return Boolean.FALSE;
}



+ 23
- 2
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,15 +873,33 @@ public class TodoCenterManage {

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

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

//设置 节点的状态 为null 代表继续审核
List<HistoricVariableInstance> approves = historyService.createHistoricVariableInstanceQuery()
.processInstanceId(dto.getInstanceId())
.variableNameLike("approve_%")
.list();
if(CollUtil.isNotEmpty(approves)){
for(HistoricVariableInstance approve : approves){
if(approve.getValue() instanceof ProcessHandlerEnum){
if(ProcessHandlerEnum.BACK.equals(ProcessHandlerEnum.getEnumByName(String.valueOf(approve.getValue())))){
runtimeService.removeVariable(approve.getProcessInstanceId(),approve.getVariableName());
break;
}
}
}
}

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

return dto.getInstanceId();
}

private Boolean modifyProject(ProjectDTO projectDto) {


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

@@ -1,16 +1,32 @@
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 com.wflow.workflow.enums.ProcessHandlerEnum;
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.flowable.variable.api.history.HistoricVariableInstance;
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 +42,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 +76,58 @@ 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());
}

@Test
public void test2(){
// 获取节点处理结果
// Map<String, ProcessHandlerEnum> varMap = historyService.createHistoricVariableInstanceQuery()
// .processInstanceId("e99fe24c-d21c-11ed-af5d-02426daa406d")
// .variableNameLike("approve_%")
// .list().stream()
// .collect(Collectors.toMap(HistoricVariableInstance::getVariableName, v -> (ProcessHandlerEnum) v.getValue()));
runtimeService.removeVariable("564102ce-d1ff-11ed-b694-02424b2b849f","approve_7d2a191a-d1ff-11ed-b694-02424b2b849f");
System.out.println(1);
}
}

+ 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