流程待办集成0.4:泛微syscode根据单据配置化

This commit is contained in:
李靖 2024-06-04 14:32:35 +08:00
parent 50e677b4d4
commit 29115f3041
1 changed files with 29 additions and 18 deletions

View File

@ -10,6 +10,7 @@ import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import com.alibaba.fastjson.JSONObject;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.logging.Log; import kd.bos.logging.Log;
import kd.bos.logging.LogFactory; import kd.bos.logging.LogFactory;
@ -25,6 +26,8 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import javax.json.JsonObject;
public class MessageListen extends AbstractMessageServiceHandler { public class MessageListen extends AbstractMessageServiceHandler {
private static final Log log = LogFactory.getLog(MessageListen.class); private static final Log log = LogFactory.getLog(MessageListen.class);
static Map<String, String> processInstanceStateMap = new HashMap(); static Map<String, String> processInstanceStateMap = new HashMap();
@ -116,7 +119,7 @@ public class MessageListen extends AbstractMessageServiceHandler {
for (Iterator<Map<String, Object>> var6 = requestBodyList.iterator(); var6.hasNext(); resultMap.get("code")) { for (Iterator<Map<String, Object>> var6 = requestBodyList.iterator(); var6.hasNext(); resultMap.get("code")) {
Map<String, Object> requestBody = var6.next(); Map<String, Object> requestBody = var6.next();
String jsonStr = pushZHData(requestBody); String jsonStr = pushZHData(requestBody);
log.info("已办任务结果~"+jsonStr); log.info("已办任务结果~" + jsonStr);
resultMap = (Map) JSON.parseObject(jsonStr, Map.class); resultMap = (Map) JSON.parseObject(jsonStr, Map.class);
resultMap.get("code"); resultMap.get("code");
if ("200".equals(resultMap.get("code"))) { if ("200".equals(resultMap.get("code"))) {
@ -184,6 +187,7 @@ public class MessageListen extends AbstractMessageServiceHandler {
Long startUserId = messageContext.getStartUserId(); Long startUserId = messageContext.getStartUserId();
String startUserMobile = ""; String startUserMobile = "";
String startUserName = ""; String startUserName = "";
String startUserTrueName = "";
Long executionId = messageContext.getExecutionId(); Long executionId = messageContext.getExecutionId();
String executionName = ""; String executionName = "";
Long taskId = messageContext.getTaskId(); Long taskId = messageContext.getTaskId();
@ -202,12 +206,14 @@ public class MessageListen extends AbstractMessageServiceHandler {
String billno = ""; String billno = "";
String title = isdel ? "流程撤回" : toDoInfo.getContent(); String title = isdel ? "流程撤回" : toDoInfo.getContent();
String entityName = messageContext.getEntityName(); String entityName = messageContext.getEntityName();
if (title != null) { // if (title != null) {
int dex = title.indexOf("", 0); // int dex = title.indexOf("", 0);
if (dex != -1) { // if (dex != -1) {
title = title.substring(dex);//截取单后面的字符串 // title = title.substring(dex);//截取单后面的字符串
} // }
} // }
// if (title == null) { // if (title == null) {
// title = "任务:" + taskId + "已办"; // title = "任务:" + taskId + "已办";
// } // }
@ -228,6 +234,7 @@ public class MessageListen extends AbstractMessageServiceHandler {
if (startUser != null) { if (startUser != null) {
startUserMobile = startUser.getString("phone"); startUserMobile = startUser.getString("phone");
startUserName = startUser.getString("username"); startUserName = startUser.getString("username");
startUserTrueName = startUser.getString("name");
} }
@ -316,17 +323,20 @@ public class MessageListen extends AbstractMessageServiceHandler {
userNames.add(startUserName); userNames.add(startUserName);
List<Map<String, Object>> requestBodyList = new ArrayList(); List<Map<String, Object>> requestBodyList = new ArrayList();
Iterator var47 = userNames.iterator(); Iterator var47 = userNames.iterator();
String syscode = System.getProperty("cxkg.integration.MessageListen.oakey");
JSONObject jsonCode = JSON.parseObject(syscode);
title = "请处理" + startUserTrueName + "提交的" + entityName + "" + messageContext.getBillNo();
while (var47.hasNext()) { while (var47.hasNext()) {
String userName = (String) var47.next(); String userName = (String) var47.next();
if (userName.equals(startUserName)) { if (userName.equals(startUserName)) {
Map<String, Object> requestBody = new HashMap(); Map<String, Object> requestBody = new HashMap();
requestBody.put("syscode", "JD"); requestBody.put("syscode", jsonCode.getString(entityName));
requestBody.put("flowid", String.valueOf(processInstanceId)); requestBody.put("flowid", String.valueOf(processInstanceId));
requestBody.put("requestname", "主题:"+title); requestBody.put("requestname", title);
requestBody.put("workflowname", entityName + "审批流程"); requestBody.put("workflowname", entityName); // + "审批流程"
requestBody.put("nodename", taskName); requestBody.put("nodename", taskName);
requestBody.put("pcurl", url+"&closeType=closeWin"); requestBody.put("pcurl", url + "&closeType=closeWin");
requestBody.put("appurl", url != null ? getAppurl(url) : null); requestBody.put("appurl", url != null ? getAppurl(url) : null);
requestBody.put("isremark", String.valueOf(tasktype)); requestBody.put("isremark", String.valueOf(tasktype));
requestBody.put("viewtype", "1"); requestBody.put("viewtype", "1");
@ -342,15 +352,15 @@ public class MessageListen extends AbstractMessageServiceHandler {
// requestBodyList.add(requestBody); // requestBodyList.add(requestBody);
} else { } else {
Map<String, Object> requestBody = new HashMap(); Map<String, Object> requestBody = new HashMap();
requestBody.put("syscode", "JD"); requestBody.put("syscode", jsonCode.getString(entityName));
requestBody.put("flowid", String.valueOf(processInstanceId)); requestBody.put("flowid", String.valueOf(processInstanceId));
if(title!=null){ if (title != null) {
requestBody.put("requestname", title); requestBody.put("requestname", title);
}else{ } else {
requestBody.put("requestname", entityName); requestBody.put("requestname", entityName);
} }
requestBody.put("workflowname", entityName + "审批流程"); requestBody.put("workflowname", entityName);// + "审批流程"
requestBody.put("nodename", taskName); requestBody.put("nodename", taskName);
requestBody.put("pcurl", url); requestBody.put("pcurl", url);
requestBody.put("appurl", getAppurl(url)); requestBody.put("appurl", getAppurl(url));
@ -642,7 +652,8 @@ public class MessageListen extends AbstractMessageServiceHandler {
// String kd21_largetextfield = kd21_oa_matters.getString("kd21_largetextfield"); // String kd21_largetextfield = kd21_oa_matters.getString("kd21_largetextfield");
// String apiUrl = kd21_largetextfield; // String apiUrl = kd21_largetextfield;
// "/api/hrm/resful/getHrmUserInfoWithPage" // "/api/hrm/resful/getHrmUserInfoWithPage"
String apiUrl = "http://" + "10.157.226.9:8088" + "/rest/ofs/ReceiveRequestInfoByJson"; // "http://" + "10.157.226.9:8088"
String apiUrl = System.getProperty("cxkg.integration.MessageListen.apiUrl") + "/rest/ofs/ReceiveRequestInfoByJson";
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON); headers.setContentType(MediaType.APPLICATION_JSON);
@ -695,7 +706,7 @@ public class MessageListen extends AbstractMessageServiceHandler {
conn.setRequestProperty("accept", "*/*"); conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive"); conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"); conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
if (data != null){ if (data != null) {
for (Map.Entry<String, String> entry : data.entrySet()) { for (Map.Entry<String, String> entry : data.entrySet()) {
conn.setRequestProperty(entry.getKey(), entry.getValue()); conn.setRequestProperty(entry.getKey(), entry.getValue());
} }
@ -761,7 +772,7 @@ public class MessageListen extends AbstractMessageServiceHandler {
// DynamicObject kd21_oa_matters = BusinessDataServiceHelper.loadSingle("kd21_oa_matters", "id,name,kd21_largetextfield", new QFilter[]{filter}); // DynamicObject kd21_oa_matters = BusinessDataServiceHelper.loadSingle("kd21_oa_matters", "id,name,kd21_largetextfield", new QFilter[]{filter});
// String kd21_largetextfield = kd21_oa_matters.getString("kd21_largetextfield"); // String kd21_largetextfield = kd21_oa_matters.getString("kd21_largetextfield");
// String apiUrl = kd21_largetextfield; // String apiUrl = kd21_largetextfield;
String apiUrl = "http://" + "10.157.226.9:8088" + "/rest/ofs/deleteUserRequestInfoByJson"; String apiUrl = System.getProperty("cxkg.integration.MessageListen.apiUrl") + "/rest/ofs/deleteUserRequestInfoByJson";
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON); headers.setContentType(MediaType.APPLICATION_JSON);