|
@@ -0,0 +1,151 @@
|
|
|
+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 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.LinkedHashMap;
|
|
|
+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;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发起流程
|
|
|
+ * @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()){
|
|
|
+ return JSON.parseObject(responseEntity2.getBody());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取待办任务
|
|
|
+ * @param todoTask
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public JSONObject 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"));
|
|
|
+// MultiValueMap<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(todoTask), LinkedMultiValueMap.class);
|
|
|
+ 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()){
|
|
|
+ return JSON.parseObject(responseEntity2.getBody());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 流程审批
|
|
|
+ * @param isOkAction
|
|
|
+ * @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()){
|
|
|
+ return JSON.parseObject(responseEntity2.getBody());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取业务id
|
|
|
+ * @param id
|
|
|
+ * @param iamCode
|
|
|
+ * @param request
|
|
|
+ * @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;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|