|
@@ -1,15 +1,20 @@
|
|
|
package com.zjugis.business.flow.contract.event;
|
|
|
|
|
|
import com.zjugis.business.bean.entity.Contract;
|
|
|
+import com.zjugis.business.bean.entity.Project;
|
|
|
import com.zjugis.business.constants.FlowStatusConstants;
|
|
|
import com.zjugis.business.flow.contract.service.FlowContractService;
|
|
|
import com.zjugis.business.service.ContractService;
|
|
|
+import com.zjugis.business.service.ProjectService;
|
|
|
+import com.zjugis.framework.common.pojo.CommonResult;
|
|
|
import com.zjugis.framework.workflow.exception.BusinessException;
|
|
|
import com.zjugis.framework.workflow.model.BaseController;
|
|
|
import com.zjugis.framework.workflow.rpc.remote.WorkflowClient;
|
|
|
import com.zjugis.framework.workflow.spring.resovler.ParamModel;
|
|
|
import com.zjugis.module.system.api.dept.DeptApi;
|
|
|
+import com.zjugis.module.system.api.dept.dto.DeptRespDTO;
|
|
|
import com.zjugis.module.system.api.user.AdminUserApi;
|
|
|
+import com.zjugis.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -20,10 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @author ljy
|
|
@@ -40,6 +42,9 @@ public class ContractEvent extends BaseController {
|
|
|
@Resource
|
|
|
private FlowContractService flowContractService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProjectService projectService;
|
|
|
+
|
|
|
@Autowired
|
|
|
WorkflowClient workflowClient;
|
|
|
|
|
@@ -261,4 +266,105 @@ public class ContractEvent extends BaseController {
|
|
|
return error(ex.getMessage(), ErrorCode.DEFAULT);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/to-manager")
|
|
|
+ public String toMainTypeFlow1(String flowInstanceId) {
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNotBlank(flowInstanceId)) {
|
|
|
+ Contract entity = contractService.selectByInstanceId(flowInstanceId);
|
|
|
+ Project project = projectService.selectById(entity.getProjectId());
|
|
|
+ List<Map<String, String>> userMaps = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotBlank(project.getXmjlId())) {
|
|
|
+ CommonResult<AdminUserRespDTO> userRes = adminUserApi.getUserLeader(project.getXmjlId());
|
|
|
+ AdminUserRespDTO userLeader = userRes.getCheckedData();
|
|
|
+ if (userLeader != null) {
|
|
|
+ HashMap<String, String> leaderMap = new HashMap<>();
|
|
|
+ leaderMap.put("id", userLeader.getId());
|
|
|
+ userMaps.add(leaderMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(project.getZrbmId())){
|
|
|
+ CommonResult<DeptRespDTO> result = deptApi.getDept(project.getZrbmId());
|
|
|
+ DeptRespDTO dept = result.getCheckedData();
|
|
|
+ if(dept != null && StringUtils.isNotBlank(dept.getLeaderUserId())){
|
|
|
+ HashMap<String,String> map = new HashMap<>();
|
|
|
+ map.put("id",dept.getLeaderUserId());
|
|
|
+ userMaps.add(map);
|
|
|
+ CommonResult<AdminUserRespDTO> userRes = adminUserApi.getUserLeader(dept.getLeaderUserId());
|
|
|
+ AdminUserRespDTO userLeader = userRes.getCheckedData();
|
|
|
+ if(userLeader != null){
|
|
|
+ HashMap<String,String> leaderMap = new HashMap<>();
|
|
|
+ leaderMap.put("id",userLeader.getId());
|
|
|
+ userMaps.add(leaderMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ok(userMaps);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("找不到流程id");
|
|
|
+ }
|
|
|
+ } catch(Exception ex){
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/to-market-manager")
|
|
|
+ public String toMarketManager(String flowInstanceId) {
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNotBlank(flowInstanceId)) {
|
|
|
+ Contract entity = contractService.selectByInstanceId(flowInstanceId);
|
|
|
+ Project project = projectService.selectById(entity.getProjectId());
|
|
|
+ List<Map<String, String>> userMaps = new ArrayList<>();
|
|
|
+ if(StringUtils.isNotBlank(project.getXsryId())){
|
|
|
+ CommonResult<AdminUserRespDTO> userRes = adminUserApi.getUserLeader(project.getXsryId());
|
|
|
+ AdminUserRespDTO userLeader = userRes.getCheckedData();
|
|
|
+ if(userLeader != null){
|
|
|
+ HashMap<String,String> leaderMap = new HashMap<>();
|
|
|
+ leaderMap.put("id",userLeader.getId());
|
|
|
+ userMaps.add(leaderMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ok(userMaps);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("找不到流程id");
|
|
|
+ }
|
|
|
+ } catch(Exception ex){
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/to-market-leader")
|
|
|
+ public String toMarketLeader(String flowInstanceId) {
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNotBlank(flowInstanceId)) {
|
|
|
+ Contract entity = contractService.selectByInstanceId(flowInstanceId);
|
|
|
+ Project project = projectService.selectById(entity.getProjectId());
|
|
|
+ List<Map<String, String>> userMaps = new ArrayList<>();
|
|
|
+ if(StringUtils.isNotBlank(project.getXsryId())){
|
|
|
+ CommonResult<AdminUserRespDTO> res = adminUserApi.getUserLeader(project.getXsryId());
|
|
|
+ if(res.getCheckedData()!= null) {
|
|
|
+ CommonResult<AdminUserRespDTO> userRes = adminUserApi.getUserLeader(res.getCheckedData().getId());
|
|
|
+ AdminUserRespDTO userLeader = userRes.getCheckedData();
|
|
|
+ if (userLeader != null) {
|
|
|
+ HashMap<String, String> leaderMap = new HashMap<>();
|
|
|
+ leaderMap.put("id", userLeader.getId());
|
|
|
+ userMaps.add(leaderMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ok(userMaps);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("找不到流程id");
|
|
|
+ }
|
|
|
+ } catch(Exception ex){
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|