From 0766c42639d0e9b12d8dc2f93589b4713ced57a6 Mon Sep 17 00:00:00 2001
From: weicd <weicd@yhzhg.cn>
Date: Fri, 27 Dec 2024 07:19:36 +0000
Subject: [PATCH] 修改
---
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/impl/BusinessExpenseServiceFlowableImpl.java | 75 ++++++++++++++++++++++++++++++-------
1 files changed, 61 insertions(+), 14 deletions(-)
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/impl/BusinessExpenseServiceFlowableImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/impl/BusinessExpenseServiceFlowableImpl.java
index 63d6be9..2b82190 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/impl/BusinessExpenseServiceFlowableImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/service/impl/BusinessExpenseServiceFlowableImpl.java
@@ -16,26 +16,27 @@
package me.zhengjie.modules.business.service.impl;
import com.alibaba.fastjson.JSONArray;
-import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.api.Api;
import me.zhengjie.modules.business.service.BusinessExpenseFlowableService;
import me.zhengjie.modules.business.service.BusinessPlanService;
import me.zhengjie.modules.business.service.dto.BusinessExpenseDto;
-import me.zhengjie.modules.business.service.dto.BusinessExpenseQueryCriteria;
import me.zhengjie.modules.business.service.dto.BusinessExpenseReimbursementDto;
import me.zhengjie.modules.business.service.dto.BusinessPlanDto;
+import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.project.service.ProjectService;
import me.zhengjie.modules.project.service.dto.ProjectDto;
-import me.zhengjie.utils.HttpUtil;
+import me.zhengjie.modules.system.domain.Role;
+import me.zhengjie.modules.system.domain.User;
+import me.zhengjie.modules.system.repository.RoleRepository;
+import me.zhengjie.modules.system.repository.UserRepository;
import me.zhengjie.utils.ObjectUtil;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.ResponseEntity;
+import me.zhengjie.utils.SecurityUtils;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -50,22 +51,49 @@
@RequiredArgsConstructor
public class BusinessExpenseServiceFlowableImpl implements BusinessExpenseFlowableService {
+ @Value("${flowable.url}")
+ private String flowableUrl;
+
private final Api api;
private final BusinessPlanService businessPlanService;
private final ProjectService projectService;
+ private final RoleRepository roleRepository;
+ private final UserRepository userRepository;
/**
- * 查询
- * @param criteria 条件参数
+ * 我发起的
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
- public Map<String, Object> queryAll(BusinessExpenseQueryCriteria criteria) throws Exception {
+ public Map<String, Object> report() throws Exception {
+ // 发起通信
+ Object returnObject = api.post(flowableUrl + "/api/common/report?key=" + "businessExpenseApply" + "&userId=" + SecurityUtils.getCurrentUserId(), new HashMap<>());
+ // 查询处理
+ return queryHandle(returnObject);
+ }
+
+ /**
+ * 待审批的
+ * @return
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public Map<String, Object> approve() throws Exception {
+ // 发起通信
+ Object returnObject = api.post(flowableUrl + "/api/common/approve?key=" + "businessExpenseApply" + "&userId=" + SecurityUtils.getCurrentUserId(), new HashMap<>());
+ // 查询处理
+ return queryHandle(returnObject);
+ }
+
+ /**
+ * 查询处理
+ * @param returnObject
+ * @return
+ */
+ private Map<String, Object> queryHandle(Object returnObject) {
// 返回结果
Map<String, Object> returnMap = new HashMap<>();
- // 发起通信
- Object returnObject = api.post("http://localhost:8888/api/common/query?key=" + "businessExpenseApply", ObjectUtil.toObjectMap(criteria));
// 通信结果转DTO
List<BusinessExpenseDto> businessExpenseDtoList = ((JSONArray) returnObject).toJavaList(BusinessExpenseDto.class);
// 循环DTO
@@ -100,8 +128,27 @@
@Override
@Transactional(rollbackFor = Exception.class)
public void create(BusinessExpenseDto resources) throws Exception {
+ // 查询指定角色
+ Role role = roleRepository.findByLevel(Constant.ROLE_LEVEL_FINANCE.intValue());
+ // 查询指定角色用户
+ List<User> userList = userRepository.findByRoleId(role.getId());
+ // 审批人字符串
+ String approver = "";
+ // 循环指定角色用户
+ for (int i = 0; i < userList.size(); i ++) {
+ if (i == 0) {
+ // 审批人字符串
+ approver = userList.get(i).getId().toString();
+ } else {
+ // 审批人字符串
+ approver += "," + userList.get(i).getId().toString();
+ }
+ }
+ // 参数
+ Map<String, Object> params = ObjectUtil.toObjectMap(resources);
+ params.put("approver", approver);
// 发起通信
- api.post("http://localhost:8888/api/common/run?key=" + "businessExpenseApply", ObjectUtil.toObjectMap(resources));
+ api.post(flowableUrl + "/api/common/run?key=" + "businessExpenseApply" + "&userId=" + SecurityUtils.getCurrentUserId(), params);
}
/**
@@ -115,7 +162,7 @@
Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("approve", "true");
// 发起通信
- api.post("http://localhost:8888/api/common/next?processInstanceId=" + processInstanceId, paramsMap);
+ api.post(flowableUrl + "/api/common/next?processInstanceId=" + processInstanceId, paramsMap);
}
/**
@@ -129,6 +176,6 @@
Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("approve", "false");
// 发起通信
- api.post("http://localhost:8888/api/common/next?processInstanceId=" + processInstanceId, paramsMap);
+ api.post(flowableUrl + "/api/common/next?processInstanceId=" + processInstanceId, paramsMap);
}
}
\ No newline at end of file
--
Gitblit v1.9.3