|
@@ -1,20 +1,25 @@
|
|
|
package com.zjugis.business.flow.commoncost.event;
|
|
|
|
|
|
-import com.google.common.base.Strings;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import com.zjugis.business.bean.entity.Project;
|
|
|
import com.zjugis.business.converter.commoncost.CommonCostConvert;
|
|
|
import com.zjugis.business.flow.commoncost.entity.CommonCostDO;
|
|
|
import com.zjugis.business.flow.commoncost.service.CommonCostDetailService;
|
|
|
import com.zjugis.business.flow.commoncost.service.CommonCostService;
|
|
|
-import com.zjugis.business.flow.leave.entity.LeaveDO;
|
|
|
-import com.zjugis.business.flow.leave.service.LeaveTimeService;
|
|
|
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.adm.api.attendance.AttendanceSheetApi;
|
|
|
-import com.zjugis.module.system.api.permission.RoleApi;
|
|
|
-import com.zjugis.module.system.api.permission.dto.RoleRespDto;
|
|
|
+import com.zjugis.module.system.api.dept.DeptApi;
|
|
|
+import com.zjugis.module.system.api.dept.DeptLeaderApi;
|
|
|
+import com.zjugis.module.system.api.dept.PostApi;
|
|
|
+import com.zjugis.module.system.api.dept.dto.DeptLeaderRespDTO;
|
|
|
+import com.zjugis.module.system.api.dept.dto.DeptRespDTO;
|
|
|
+import com.zjugis.module.system.api.dept.dto.PostRespDTO;
|
|
|
+import com.zjugis.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
@@ -24,10 +29,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.*;
|
|
|
|
|
|
import static com.zjugis.business.constants.FlowStatusConstants.*;
|
|
|
import static com.zjugis.framework.common.util.collection.CollectionUtils.convertSet;
|
|
@@ -52,7 +54,11 @@ public class CommonCostEvent extends BaseController {
|
|
|
@Resource
|
|
|
private WorkflowClient workflowClient;
|
|
|
@Resource
|
|
|
- private RoleApi roleApi;
|
|
|
+ private PostApi postApi;
|
|
|
+ @Resource
|
|
|
+ private DeptApi deptApi;
|
|
|
+ @Resource
|
|
|
+ private DeptLeaderApi deptLeaderApi;
|
|
|
|
|
|
/**
|
|
|
* 设置流程描述
|
|
@@ -67,12 +73,9 @@ public class CommonCostEvent extends BaseController {
|
|
|
if (!Objects.isNull(activityInstance) && activityInstance.containsKey("flowInstanceId")) {
|
|
|
String flowInstanceId = activityInstance.get("flowInstanceId").toString();
|
|
|
CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
- String flowDesc = "";
|
|
|
- if (!Strings.isNullOrEmpty(entity.getUserNickname())) {
|
|
|
- flowDesc += "/" + entity.getUserNickname();
|
|
|
- }
|
|
|
entity.setFlowStatus(FLOW_PROCESS);
|
|
|
commonCostService.updateCommonCost(CommonCostConvert.INSTANCE.convert(entity));
|
|
|
+ String flowDesc = StringUtils.join(Arrays.asList(entity.getUserNickname(), entity.getTotalAmount()), "/");
|
|
|
flowDesc = flowDesc.length() > 1 ? flowDesc.substring(1) : flowDesc;
|
|
|
workflowClient.saveFlowDescribe(flowInstanceId, flowDesc);
|
|
|
return ok("true");
|
|
@@ -194,7 +197,7 @@ public class CommonCostEvent extends BaseController {
|
|
|
}
|
|
|
|
|
|
@PostMapping("/lessThan2000")
|
|
|
- public String le2000(@ParamModel Map flowInstance, @ParamModel Map flowDirectionInstance, @ParamModel Map previousActivityInstance, @ParamModel Map previousGatewayInstance, @ParamModel Map nextActivityTemplate, @ParamModel Map nextGatewayInstance) {
|
|
|
+ public String lessThan2000(@ParamModel Map flowInstance, @ParamModel Map flowDirectionInstance, @ParamModel Map previousActivityInstance, @ParamModel Map previousGatewayInstance, @ParamModel Map nextActivityTemplate, @ParamModel Map nextGatewayInstance) {
|
|
|
try {
|
|
|
String flowInstanceId = flowInstance.get("id").toString();
|
|
|
CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
@@ -209,7 +212,7 @@ public class CommonCostEvent extends BaseController {
|
|
|
}
|
|
|
|
|
|
@PostMapping("/ge2000")
|
|
|
- public String greatThan7(@ParamModel Map flowInstance, @ParamModel Map flowDirectionInstance, @ParamModel Map previousActivityInstance, @ParamModel Map previousGatewayInstance, @ParamModel Map nextActivityTemplate, @ParamModel Map nextGatewayInstance) {
|
|
|
+ public String ge2000(@ParamModel Map flowInstance, @ParamModel Map flowDirectionInstance, @ParamModel Map previousActivityInstance, @ParamModel Map previousGatewayInstance, @ParamModel Map nextActivityTemplate, @ParamModel Map nextGatewayInstance) {
|
|
|
try {
|
|
|
String flowInstanceId = flowInstance.get("id").toString();
|
|
|
CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
@@ -223,15 +226,76 @@ public class CommonCostEvent extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/lessThan10000")
|
|
|
+ public String lessThan10000(@ParamModel Map flowInstance, @ParamModel Map flowDirectionInstance, @ParamModel Map previousActivityInstance, @ParamModel Map previousGatewayInstance, @ParamModel Map nextActivityTemplate, @ParamModel Map nextGatewayInstance) {
|
|
|
+ try {
|
|
|
+ String flowInstanceId = flowInstance.get("id").toString();
|
|
|
+ CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
+ if (entity != null && entity.getTotalAmount() != null
|
|
|
+ && entity.getTotalAmount().compareTo(new BigDecimal(10000)) < 0) {
|
|
|
+ return "true";
|
|
|
+ }
|
|
|
+ return "false";
|
|
|
+ } catch (Exception ex) {
|
|
|
+ return error(ex.getMessage(), ErrorCode.DEFAULT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/ge10000")
|
|
|
+ public String ge10000(@ParamModel Map flowInstance, @ParamModel Map flowDirectionInstance, @ParamModel Map previousActivityInstance, @ParamModel Map previousGatewayInstance, @ParamModel Map nextActivityTemplate, @ParamModel Map nextGatewayInstance) {
|
|
|
+ try {
|
|
|
+ String flowInstanceId = flowInstance.get("id").toString();
|
|
|
+ CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
+ if (entity != null && entity.getTotalAmount() != null
|
|
|
+ && entity.getTotalAmount().compareTo(new BigDecimal(10000)) >= 0) {
|
|
|
+ return "true";
|
|
|
+ }
|
|
|
+ return "false";
|
|
|
+ } catch (Exception ex) {
|
|
|
+ return error(ex.getMessage(), ErrorCode.DEFAULT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("/toManager")
|
|
|
public String toManager(@ParamModel Map flowInstance, @ParamModel Map flowDirectionInstance, @ParamModel Map previousActivityInstance, @ParamModel Map previousGatewayInstance, @ParamModel Map nextActivityTemplate, @ParamModel Map nextGatewayInstance) {
|
|
|
try {
|
|
|
String flowInstanceId = flowInstance.get("id").toString();
|
|
|
CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
- List<RoleRespDto> roleList = roleApi.getRoleByUser(entity.getUserId()).getCheckedData();
|
|
|
- Set<String> roleName = convertSet(roleList, RoleRespDto::getName);
|
|
|
- if (entity != null && entity.getTotalAmount() != null
|
|
|
- && entity.getTotalAmount().compareTo(new BigDecimal(2000)) >= 0) {
|
|
|
+ List<PostRespDTO> postList = postApi.getPostByUser(entity.getUserId()).getCheckedData();
|
|
|
+ Set<String> postCodes = convertSet(postList, PostRespDTO::getCode);
|
|
|
+ if (entity != null && CollectionUtil.contains(postCodes, "bmjl")) {
|
|
|
+ return "true";
|
|
|
+ }
|
|
|
+ return "false";
|
|
|
+ } catch (Exception ex) {
|
|
|
+ return error(ex.getMessage(), ErrorCode.DEFAULT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/toCommon")
|
|
|
+ public String toCommon(@ParamModel Map flowInstance, @ParamModel Map flowDirectionInstance, @ParamModel Map previousActivityInstance, @ParamModel Map previousGatewayInstance, @ParamModel Map nextActivityTemplate, @ParamModel Map nextGatewayInstance) {
|
|
|
+ try {
|
|
|
+ String flowInstanceId = flowInstance.get("id").toString();
|
|
|
+ CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
+ List<PostRespDTO> postList = postApi.getPostByUser(entity.getUserId()).getCheckedData();
|
|
|
+ Set<String> postCodes = convertSet(postList, PostRespDTO::getCode);
|
|
|
+ if (entity != null && (CollectionUtil.isEmpty(postCodes) || CollectionUtil.contains(postCodes, "user"))) {
|
|
|
+ return "true";
|
|
|
+ }
|
|
|
+ return "false";
|
|
|
+ } catch (Exception ex) {
|
|
|
+ return error(ex.getMessage(), ErrorCode.DEFAULT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/toCTO")
|
|
|
+ public String toCTO(@ParamModel Map flowInstance, @ParamModel Map flowDirectionInstance, @ParamModel Map previousActivityInstance, @ParamModel Map previousGatewayInstance, @ParamModel Map nextActivityTemplate, @ParamModel Map nextGatewayInstance) {
|
|
|
+ try {
|
|
|
+ String flowInstanceId = flowInstance.get("id").toString();
|
|
|
+ CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
+ List<PostRespDTO> postList = postApi.getPostByUser(entity.getUserId()).getCheckedData();
|
|
|
+ Set<String> postCodes = convertSet(postList, PostRespDTO::getCode);
|
|
|
+ if (entity != null && CollectionUtil.contains(postCodes, "jszj")) {
|
|
|
return "true";
|
|
|
}
|
|
|
return "false";
|
|
@@ -239,4 +303,172 @@ public class CommonCostEvent extends BaseController {
|
|
|
return error(ex.getMessage(), ErrorCode.DEFAULT);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("/toGMO")
|
|
|
+ public String toGMO(@ParamModel Map flowInstance, @ParamModel Map flowDirectionInstance, @ParamModel Map previousActivityInstance, @ParamModel Map previousGatewayInstance, @ParamModel Map nextActivityTemplate, @ParamModel Map nextGatewayInstance) {
|
|
|
+ try {
|
|
|
+ String flowInstanceId = flowInstance.get("id").toString();
|
|
|
+ CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
+ List<PostRespDTO> postList = postApi.getPostByUser(entity.getUserId()).getCheckedData();
|
|
|
+ Set<String> postCodes = convertSet(postList, PostRespDTO::getCode);
|
|
|
+ if (entity != null && (CollectionUtil.contains(postCodes, "ceo") || CollectionUtil.contains(postCodes, "ZJL"))) {
|
|
|
+ return "true";
|
|
|
+ }
|
|
|
+ return "false";
|
|
|
+ } catch (Exception ex) {
|
|
|
+ return error(ex.getMessage(), ErrorCode.DEFAULT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/toCeoProject")
|
|
|
+ public String toCeoProject(@ParamModel Map flowInstance, @ParamModel Map flowDirectionInstance, @ParamModel Map previousActivityInstance, @ParamModel Map previousGatewayInstance, @ParamModel Map nextActivityTemplate, @ParamModel Map nextGatewayInstance) {
|
|
|
+ try {
|
|
|
+ String flowInstanceId = flowInstance.get("id").toString();
|
|
|
+ CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
+ Project project = projectService.selectById(entity.getProjectId());
|
|
|
+ String xmjlId = project.getXmjlId();
|
|
|
+ String userId = entity.getUserId();
|
|
|
+ List<PostRespDTO> postList = postApi.getPostByUser(userId).getCheckedData();
|
|
|
+ Set<String> postCodes = convertSet(postList, PostRespDTO::getCode);
|
|
|
+ if (entity != null && CollectionUtil.contains(postCodes, "ceo") && userId.equals(xmjlId)) {
|
|
|
+ return "true";
|
|
|
+ }
|
|
|
+ return "false";
|
|
|
+ } catch (Exception ex) {
|
|
|
+ return error(ex.getMessage(), ErrorCode.DEFAULT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/toLeaderProject")
|
|
|
+ public String toLeaderProject(@ParamModel Map flowInstance, @ParamModel Map flowDirectionInstance, @ParamModel Map previousActivityInstance, @ParamModel Map previousGatewayInstance, @ParamModel Map nextActivityTemplate, @ParamModel Map nextGatewayInstance) {
|
|
|
+ try {
|
|
|
+ String flowInstanceId = flowInstance.get("id").toString();
|
|
|
+ CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
+ Project project = projectService.selectById(entity.getProjectId());
|
|
|
+ String xmjlId = project.getXmjlId();
|
|
|
+ String userId = entity.getUserId();
|
|
|
+ List<PostRespDTO> postList = postApi.getPostByUser(userId).getCheckedData();
|
|
|
+ Set<String> postCodes = convertSet(postList, PostRespDTO::getCode);
|
|
|
+ List<DeptRespDTO> deptChildList = deptApi.getChildDeptList(entity.getDeptId()).getCheckedData();
|
|
|
+ Set<String> depts = convertSet(deptChildList, DeptRespDTO::getId);
|
|
|
+ depts.add(entity.getDeptId());
|
|
|
+ if (entity != null && CollectionUtil.contains(postCodes, "fgslz") && userId.equals(xmjlId) && CollectionUtil.contains(depts, project.getZrbmId()) && userId.equals(xmjlId)) {
|
|
|
+ return "true";
|
|
|
+ }
|
|
|
+ return "false";
|
|
|
+ } catch (Exception ex) {
|
|
|
+ return error(ex.getMessage(), ErrorCode.DEFAULT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/toNotLeaderProject")
|
|
|
+ public String toNotLeaderProject(@ParamModel Map flowInstance, @ParamModel Map flowDirectionInstance, @ParamModel Map previousActivityInstance, @ParamModel Map previousGatewayInstance, @ParamModel Map nextActivityTemplate, @ParamModel Map nextGatewayInstance) {
|
|
|
+ try {
|
|
|
+ String flowInstanceId = flowInstance.get("id").toString();
|
|
|
+ CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
+ Project project = projectService.selectById(entity.getProjectId());
|
|
|
+ String xmjlId = project.getXmjlId();
|
|
|
+ String userId = entity.getUserId();
|
|
|
+ List<PostRespDTO> postList = postApi.getPostByUser(userId).getCheckedData();
|
|
|
+ Set<String> postCodes = convertSet(postList, PostRespDTO::getCode);
|
|
|
+ List<DeptRespDTO> deptChildList = deptApi.getChildDeptList(entity.getDeptId()).getCheckedData();
|
|
|
+ Set<String> depts = convertSet(deptChildList, DeptRespDTO::getId);
|
|
|
+ depts.add(entity.getDeptId());
|
|
|
+ if (entity != null && CollectionUtil.contains(postCodes, "fgslz") && userId.equals(xmjlId) && !CollectionUtil.contains(depts, project.getZrbmId()) && userId.equals(xmjlId)) {
|
|
|
+ return "true";
|
|
|
+ }
|
|
|
+ return "false";
|
|
|
+ } catch (Exception ex) {
|
|
|
+ return error(ex.getMessage(), ErrorCode.DEFAULT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/decrease")
|
|
|
+ public String decrease(@ParamModel Map flowInstance, @ParamModel Map flowDirectionInstance, @ParamModel Map previousActivityInstance, @ParamModel Map previousGatewayInstance, @ParamModel Map nextActivityTemplate, @ParamModel Map nextGatewayInstance) {
|
|
|
+ try {
|
|
|
+ String flowInstanceId = flowInstance.get("id").toString();
|
|
|
+ CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
+ if (entity != null && entity.getDybx()==1) {
|
|
|
+ return "true";
|
|
|
+ }
|
|
|
+ return "false";
|
|
|
+ } catch (Exception ex) {
|
|
|
+ return error(ex.getMessage(), ErrorCode.DEFAULT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/to-project-dept-manager")
|
|
|
+ public String toProjectDeptManager(String flowInstanceId) {
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNotBlank(flowInstanceId)) {
|
|
|
+ CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
+ Project project = projectService.selectById(entity.getProjectId());
|
|
|
+ List<Map<String, String>> userMaps = new ArrayList<>();
|
|
|
+ if(StringUtils.isNotBlank(project.getZrbmId())){
|
|
|
+ DeptRespDTO deptRespDTO = deptApi.getDept(project.getZrbmId()).getCheckedData();
|
|
|
+ if(deptRespDTO != null && StringUtils.isNotBlank(deptRespDTO.getLeaderUserId())){
|
|
|
+ HashMap<String,String> map = new HashMap<>();
|
|
|
+ map.put("id",deptRespDTO.getLeaderUserId());
|
|
|
+ userMaps.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ok(userMaps);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/to-project-dept-leader")
|
|
|
+ public String toProjectDeptLeader(String flowInstanceId) {
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNotBlank(flowInstanceId)) {
|
|
|
+ CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
+ Project project = projectService.selectById(entity.getProjectId());
|
|
|
+ List<Map<String, String>> userMaps = new ArrayList<>();
|
|
|
+ if(StringUtils.isNotBlank(project.getZrbmId())){
|
|
|
+ DeptLeaderRespDTO deptLeaderRespDTO = deptLeaderApi.getDeptLeaderByDeptId(project.getZrbmId()).getCheckedData();
|
|
|
+ if(deptLeaderRespDTO != null && StringUtils.isNotBlank(deptLeaderRespDTO.getUserId())){
|
|
|
+ HashMap<String,String> map = new HashMap<>();
|
|
|
+ map.put("id",deptLeaderRespDTO.getUserId());
|
|
|
+ userMaps.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ok(userMaps);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/to-project-module-leader")
|
|
|
+ public String toProjectModuleLeader(String flowInstanceId) {
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNotBlank(flowInstanceId)) {
|
|
|
+ CommonCostDO entity = commonCostService.findByInstanceId(flowInstanceId);
|
|
|
+ Project project = projectService.selectById(entity.getProjectId());
|
|
|
+ List<Map<String, String>> userMaps = new ArrayList<>();
|
|
|
+ if(StringUtils.isNotBlank(project.getZrbmId())){
|
|
|
+ DeptRespDTO deptRespDTO = deptApi.getSecondDeptByDeptId(project.getZrbmId()).getCheckedData();
|
|
|
+ if(deptRespDTO != null && StringUtils.isNotBlank(deptRespDTO.getLeaderUserId())){
|
|
|
+ HashMap<String,String> map = new HashMap<>();
|
|
|
+ map.put("id",deptRespDTO.getLeaderUserId());
|
|
|
+ userMaps.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ok(userMaps);
|
|
|
+ } else {
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
+ throw new BusinessException("执行事件出错,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|