|
@@ -1,316 +1,55 @@
|
|
|
package com.ims.eval.service.custom;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.ims.eval.config.ImaConfig;
|
|
|
-import com.ims.eval.entity.custom.DoAction;
|
|
|
-import com.ims.eval.entity.custom.IsOkAction;
|
|
|
-import com.ims.eval.entity.custom.TodoTask;
|
|
|
-import com.ims.eval.entity.flow.FlowResult;
|
|
|
-import com.ims.eval.schedule.ScoreCalculationSchedule;
|
|
|
-import com.ims.eval.service.*;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.*;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.web.client.RestTemplate;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
- * <p>
|
|
|
- * 工作流 服务实现类
|
|
|
- * </p>
|
|
|
- *
|
|
|
- * @author wang
|
|
|
- * @since 2023-03-12
|
|
|
+ * 工作流业务类
|
|
|
*/
|
|
|
-@Service
|
|
|
-@Slf4j
|
|
|
-public class WorkflowService {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private RestTemplate restTemplate;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ImaConfig imaConfig;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IDeptResponsibilityService deptResponsibilityService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IOrganizationEvaluationService organizationEvaluationService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ScoreCalculationSchedule scoreCalculationSchedule;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IEvaluationDeptBusinessPlanService evaluationDeptBusinessPlanService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IEvaluationDeptBusinessAssessmentService evaluationDeptBusinessAssessmentService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IEvaluationRevisionService evaluationRevisionService;
|
|
|
+public interface WorkflowService {
|
|
|
|
|
|
- @Autowired
|
|
|
- private IDeptAssessmentDeclarationService deptAssessmentDeclarationService;
|
|
|
-
|
|
|
-
|
|
|
- * 发起流程
|
|
|
- *
|
|
|
- * @param doAction
|
|
|
- * @return
|
|
|
- */
|
|
|
- public JSONObject doAction(DoAction doAction, HttpServletRequest request) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
|
|
- headers.add("Blade-Auth", request.getHeader("Blade-Auth"));
|
|
|
- headers.add("code", request.getHeader("code"));
|
|
|
- Map<String, String> map = new LinkedHashMap<>();
|
|
|
- map.put("iamCode", doAction.getIamCode());
|
|
|
- map.put("defKey", doAction.getDefKey());
|
|
|
- map.put("businessKey", doAction.getBusinessKey());
|
|
|
- map.put("action", doAction.getAction());
|
|
|
- map.put("opinion", doAction.getOpinion());
|
|
|
-
|
|
|
- HttpEntity<Map> param = new HttpEntity<>(map, headers);
|
|
|
- ResponseEntity<String> responseEntity2 = restTemplate.exchange("http://10.65.78.23:8080/bpm/instance/doAction", HttpMethod.POST, param, String.class);
|
|
|
- log.info("\n code:{}\n header:{}\n body:{}\n", responseEntity2.getStatusCodeValue(), responseEntity2.getHeaders(), responseEntity2.getBody());
|
|
|
- if (200 == responseEntity2.getStatusCodeValue()) {
|
|
|
- FlowResult result = JSON.parseObject(responseEntity2.getBody()).toJavaObject(FlowResult.class);
|
|
|
-
|
|
|
- if (result.getIsOk()) {
|
|
|
- boolean biz = updateWorkflowState(result.getData(), doAction.getDefKey(), doAction.getBusinessKey(), "");
|
|
|
- if (biz) {
|
|
|
- log.info("保存流程实例id成功");
|
|
|
- }
|
|
|
- }
|
|
|
- return JSON.parseObject(responseEntity2.getBody());
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * 获取待办任务
|
|
|
- *
|
|
|
- * @param todoTask
|
|
|
- * @return
|
|
|
- */
|
|
|
- public FlowResult todoTaskList(TodoTask todoTask, HttpServletRequest request) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
|
|
- headers.add("Blade-Auth", request.getHeader("Blade-Auth"));
|
|
|
- headers.add("code", request.getHeader("code"));
|
|
|
-
|
|
|
- Map<String, String> map = new LinkedHashMap<>();
|
|
|
- map.put("iamCode", todoTask.getIamCode());
|
|
|
- map.put("order", todoTask.getOrder());
|
|
|
- map.put("sort", todoTask.getSort());
|
|
|
- map.put("offset", todoTask.getOffset());
|
|
|
- map.put("limit", todoTask.getLimit());
|
|
|
- HttpEntity<Map> param = new HttpEntity<>(map, headers);
|
|
|
- ResponseEntity<String> responseEntity2 = restTemplate.exchange("http://10.65.78.23:8080/bpm/my/todoTaskList", HttpMethod.POST, param, String.class);
|
|
|
- log.info("\n code:{}\n header:{}\n body:{}\n", responseEntity2.getStatusCodeValue(), responseEntity2.getHeaders(), responseEntity2.getBody());
|
|
|
-
|
|
|
- if (200 == responseEntity2.getStatusCodeValue()) {
|
|
|
- FlowResult result = JSON.parseObject(responseEntity2.getBody()).toJavaObject(FlowResult.class);
|
|
|
- if (result.getIsOk()) {
|
|
|
- List<JSONObject> ds = new ArrayList<>();
|
|
|
- for (int i = 0; i < result.getRows().size(); i++) {
|
|
|
- String typeId = result.getRows().getJSONObject(i).get("typeId").toString();
|
|
|
- if(!"440219646351376385".equals(typeId)){
|
|
|
- ds.add(result.getRows().getJSONObject(i));
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- result.getRows().removeAll(ds);
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
- * 检查当前数据(对应的用户)是或否存在代办
|
|
|
- * @param instId
|
|
|
- * @param request
|
|
|
+ * 流程启动前
|
|
|
+ * @param instId 业务类
|
|
|
+ * @param defKey 流程key
|
|
|
+ * @param bizKey 自定义key(一般存主数据id)
|
|
|
+ * @param taskName 流程节点名称
|
|
|
* @return
|
|
|
*/
|
|
|
- public boolean todoTaskList2(String instId,HttpServletRequest request) {
|
|
|
- try {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
|
|
- headers.add("Blade-Auth", request.getHeader("Blade-Auth"));
|
|
|
- headers.add("code", request.getHeader("code"));
|
|
|
- Map<String, String> map = new LinkedHashMap<>();
|
|
|
- map.put("iamCode", request.getHeader("code"));
|
|
|
- map.put("order", "ASC");
|
|
|
- map.put("sort", "");
|
|
|
- map.put("offset", "");
|
|
|
- map.put("limit", "99999");
|
|
|
- HttpEntity<Map> param = new HttpEntity<>(map, headers);
|
|
|
- ResponseEntity<String> responseEntity2 = restTemplate.exchange("http://10.65.78.23:8080/bpm/my/todoTaskList", HttpMethod.POST, param, String.class);
|
|
|
- log.info("\n code:{}\n header:{}\n body:{}\n", responseEntity2.getStatusCodeValue(), responseEntity2.getHeaders(), responseEntity2.getBody());
|
|
|
-
|
|
|
- if (200 == responseEntity2.getStatusCodeValue()) {
|
|
|
- FlowResult result = JSON.parseObject(responseEntity2.getBody()).toJavaObject(FlowResult.class);
|
|
|
- if (result.getIsOk()) {
|
|
|
- List<JSONObject> ds = new ArrayList<>();
|
|
|
- for (int i = 0; i < result.getRows().size(); i++) {
|
|
|
- String typeId = result.getRows().getJSONObject(i).get("typeId").toString();
|
|
|
- if(!"440219646351376385".equals(typeId)){
|
|
|
- ds.add(result.getRows().getJSONObject(i));
|
|
|
- continue;
|
|
|
- }
|
|
|
- String resinstId = result.getRows().getJSONObject(i).get("instId").toString();
|
|
|
- if(instId.equals(resinstId)){
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- return false;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ boolean beforeStartAction(String instId, String defKey, String bizKey,String taskName);
|
|
|
|
|
|
|
|
|
- * 流程审批
|
|
|
- * @param isOkAction
|
|
|
+ * 流程启动后
|
|
|
+ * @param instId 业务类
|
|
|
+ * @param defKey 流程key
|
|
|
+ * @param bizKey 自定义key(一般存主数据id)
|
|
|
+ * @param taskName 流程节点名称
|
|
|
* @return
|
|
|
*/
|
|
|
- public JSONObject isOkAction(IsOkAction isOkAction, HttpServletRequest request){
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
|
|
- headers.add("Blade-Auth", request.getHeader("Blade-Auth"));
|
|
|
- headers.add("code", request.getHeader("code"));
|
|
|
- Map<String, String> map = new LinkedHashMap<>();
|
|
|
-
|
|
|
- map.put("taskId",isOkAction.getTaskId());
|
|
|
- map.put("nodeId",isOkAction.getNodeId());
|
|
|
- map.put("action",isOkAction.getAction());
|
|
|
-
|
|
|
- if(!"agree".equals(isOkAction.getAction())){
|
|
|
- map.put("destination",isOkAction.getDestination());
|
|
|
- }
|
|
|
- map.put("instanceId",isOkAction.getInstanceId());
|
|
|
- map.put("opinion",isOkAction.getOpinion());
|
|
|
- map.put("iamCode",isOkAction.getIamCode());
|
|
|
- HttpEntity<Map> param = new HttpEntity<>(map, headers);
|
|
|
- ResponseEntity<String> responseEntity2 = restTemplate.exchange("http://10.65.78.23:8080/bpm/task/doAction", HttpMethod.POST,param,String.class);
|
|
|
- log.info("\n code:{}\n header:{}\n body:{}\n", responseEntity2.getStatusCodeValue(), responseEntity2.getHeaders(), responseEntity2.getBody());
|
|
|
- if(200== responseEntity2.getStatusCodeValue()){
|
|
|
-
|
|
|
- FlowResult result = JSON.parseObject(responseEntity2.getBody()).toJavaObject(FlowResult.class);
|
|
|
- if(result.getIsOk()){
|
|
|
- boolean biz = updateWorkflowState("",isOkAction.getDefKey(),isOkAction.getBizKey(),isOkAction.getTaskName());
|
|
|
- if(biz){
|
|
|
- log.info("状态修改成功");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return JSON.parseObject(responseEntity2.getBody());
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
+ boolean afterStartAction(String instId, String defKey, String bizKey,String taskName);
|
|
|
|
|
|
|
|
|
|
|
|
- * 获取业务id
|
|
|
- * @param id
|
|
|
- * @param iamCode
|
|
|
- * @param request
|
|
|
+ * 流程审批前
|
|
|
+ * @param instId 业务类
|
|
|
+ * @param defKey 流程key
|
|
|
+ * @param bizKey 自定义key(一般存主数据id)
|
|
|
+ * @param taskName 流程节点名称
|
|
|
* @return
|
|
|
*/
|
|
|
- public JSONObject getInstanceAndChildren(String id,String iamCode, HttpServletRequest request){
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
|
|
- headers.add("Blade-Auth", request.getHeader("Blade-Auth"));
|
|
|
- headers.add("code", request.getHeader("code"));
|
|
|
-
|
|
|
- HttpEntity<Map> param = new HttpEntity<>(null, headers);
|
|
|
- ResponseEntity<String> responseEntity2 = restTemplate.postForEntity("http://10.65.78.23:8080/bpm/instance/getInstanceAndChildren?id={1}&iamCode={2}",
|
|
|
- param, String.class, id, iamCode);
|
|
|
-
|
|
|
- log.info("\n code:{}\n header:{}\n body:{}\n", responseEntity2.getStatusCodeValue(), responseEntity2.getHeaders(), responseEntity2.getBody());
|
|
|
- if(200== responseEntity2.getStatusCodeValue()){
|
|
|
- return JSON.parseObject(responseEntity2.getBody());
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
+ boolean beforeCheckAction(String instId, String defKey, String bizKey, String taskName);
|
|
|
|
|
|
|
|
|
|
|
|
- * 获取流程审批意见
|
|
|
- * @param instId
|
|
|
- * @param iamCode
|
|
|
- * @param request
|
|
|
+ * 流程审批后
|
|
|
+ * @param instId 业务类
|
|
|
+ * @param defKey 流程key
|
|
|
+ * @param bizKey 自定义key(一般存主数据id)
|
|
|
+ * @param taskName 流程节点名称
|
|
|
* @return
|
|
|
*/
|
|
|
- public JSONObject getOpinion(String instId,String iamCode, HttpServletRequest request){
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
|
|
- headers.add("Blade-Auth", request.getHeader("Blade-Auth"));
|
|
|
- headers.add("code", request.getHeader("code"));
|
|
|
-
|
|
|
- HttpEntity<Map> param = new HttpEntity<>(null, headers);
|
|
|
- ResponseEntity<String> responseEntity2 = restTemplate.postForEntity("http://10.65.78.23:8080/bpm/instance/getOpinion?instId={1}&iamCode={2}",
|
|
|
- param, String.class, instId, iamCode);
|
|
|
-
|
|
|
- log.info("\n code:{}\n header:{}\n body:{}\n", responseEntity2.getStatusCodeValue(), responseEntity2.getHeaders(), responseEntity2.getBody());
|
|
|
- if(200== responseEntity2.getStatusCodeValue()){
|
|
|
- return JSON.parseObject(responseEntity2.getBody());
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- private boolean updateWorkflowState(String instId, String defKey, String bizKey,String taskName) {
|
|
|
-
|
|
|
- switch (defKey) {
|
|
|
- case "dwkpmbqd":
|
|
|
- deptResponsibilityService.editState(bizKey,taskName,instId);
|
|
|
- break;
|
|
|
- case "yddwkplc":
|
|
|
- organizationEvaluationService.editState(bizKey, taskName,instId);
|
|
|
- break;
|
|
|
- case "jddwkplc":
|
|
|
- organizationEvaluationService.editState(bizKey, taskName,instId);
|
|
|
- break;
|
|
|
- case "nddwkplc":
|
|
|
- organizationEvaluationService.editState(bizKey, taskName,instId);
|
|
|
- break;
|
|
|
- case "dwkpmbxd":
|
|
|
- evaluationRevisionService.editState(bizKey,taskName,instId);
|
|
|
- break;
|
|
|
- case "bbbmyjzbjh":
|
|
|
- evaluationDeptBusinessPlanService.editState(bizKey,taskName,instId);
|
|
|
- break;
|
|
|
- case "bbbmyjzbkh":
|
|
|
- evaluationDeptBusinessAssessmentService.editState(bizKey,taskName,instId);
|
|
|
- break;
|
|
|
- case "jxjgkhsb":
|
|
|
- deptAssessmentDeclarationService.editState(bizKey,taskName,instId);
|
|
|
- break;
|
|
|
- }
|
|
|
- return true;
|
|
|
-
|
|
|
- }
|
|
|
+ boolean afterCheckAction(String instId, String defKey, String bizKey, String taskName);
|
|
|
|
|
|
|
|
|
|