diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java index 22ea593..8bdc2bc 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/DefaultDeclaredProjectManage.java @@ -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)); + } } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java index a01c057..eb6eba9 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java @@ -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(); } diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/instance/InstanceTest.java b/pmapi/src/test/java/com/ningdatech/pmapi/instance/InstanceTest.java index 3027063..6273194 100644 --- a/pmapi/src/test/java/com/ningdatech/pmapi/instance/InstanceTest.java +++ b/pmapi/src/test/java/com/ningdatech/pmapi/instance/InstanceTest.java @@ -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 projects = projectLibManage.projectList(projectListReq); + Map projectsMap = projects.stream().collect(Collectors.toMap(Project::getId, v -> v)); + // 再查出项目关联的流程实例ID + List projectIdList = projects.stream().map(Project::getId).collect(Collectors.toList()); + if (CollUtil.isEmpty(projectIdList)) { + System.out.println("没有项目"); + return; + } + List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) + .in(ProjectInst::getProjectId, projectIdList) + .orderByDesc(ProjectInst::getProjectId)); + Map projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); + List 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 taskInstances = taskInstanceQuery.list(); + + Set set = new HashSet(); + List 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()); + } } diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/stream/stream.java b/pmapi/src/test/java/com/ningdatech/pmapi/stream/stream.java new file mode 100644 index 0000000..7de6137 --- /dev/null +++ b/pmapi/src/test/java/com/ningdatech/pmapi/stream/stream.java @@ -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 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 set = list.stream().collect(Collectors.toSet()); + System.out.println(set); + } + +}