From 81caa915a9e54a93702e32adf2ac1deb7f5c454a Mon Sep 17 00:00:00 2001 From: zengweihai Date: Wed, 24 Jul 2024 12:33:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E6=8D=AE=E5=AE=A1=E6=89=B9=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cxkg/integration/MessageListen.java | 93 ++++++++++++++++++- .../shkd/plugin/ApprovalBillFormPlugin.java | 26 +++++- 2 files changed, 114 insertions(+), 5 deletions(-) diff --git a/shkd-cosmic-debug/src/main/java/shkd/cosmic/cxkg/integration/MessageListen.java b/shkd-cosmic-debug/src/main/java/shkd/cosmic/cxkg/integration/MessageListen.java index 56368a6..b74a63f 100644 --- a/shkd-cosmic-debug/src/main/java/shkd/cosmic/cxkg/integration/MessageListen.java +++ b/shkd-cosmic-debug/src/main/java/shkd/cosmic/cxkg/integration/MessageListen.java @@ -14,8 +14,10 @@ import com.alibaba.fastjson.JSONObject; import kd.bos.dataentity.entity.DynamicObject; import kd.bos.logging.Log; import kd.bos.logging.LogFactory; +import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.user.UserServiceHelper; import kd.bos.workflow.engine.msg.AbstractMessageServiceHandler; import kd.bos.workflow.engine.msg.ctx.MessageContext; import kd.bos.workflow.engine.msg.info.MessageInfo; @@ -152,6 +154,28 @@ public class MessageListen extends AbstractMessageServiceHandler { } } + public void sendMessage(HashMap map) { + log.info("消息通知~~~~~~~~~~"); + List> requestBodyList = getRequestBodyList3(map); + log.info("推送消息通知内容:{}", requestBodyList); + + + Map resultMap; + for (Iterator var6 = requestBodyList.iterator(); var6.hasNext(); resultMap.get("code")) { + Map requestBody = (Map) var6.next(); + String jsonStr = this.pushZHData(requestBody); + log.info("传阅结果 jsonStr:" + jsonStr); + resultMap = (Map) JSON.parseObject(jsonStr, Map.class); + resultMap.get("errcode"); + if ("0".equals(resultMap.get("errcode"))) { + log.info("推送已办任务内容成功"); + } else { + log.info("推送已办任务内容失败"); + } + } + } + + public void deleteToDo(MessageContext messageContext, ToDoInfo toDoInfo) { log.info("删除待办~~~~~~~~~~"); @@ -490,7 +514,6 @@ public class MessageListen extends AbstractMessageServiceHandler { } List> requestBodyList = new ArrayList(); - Iterator var21 = userNames.iterator(); String syscodestr = System.getProperty("cxkg.integration.MessageListen.oakey"); JSONObject jsonCode = JSON.parseObject(syscodestr); String syscode = jsonCode.getString(entityName); @@ -504,7 +527,7 @@ public class MessageListen extends AbstractMessageServiceHandler { if(entityName != null && entityName.startsWith("差旅报销单")){ entityName = "差旅报销单"; } - + Iterator var21 = userNames.iterator(); int i = 1; while (var21.hasNext()) { String username = (String) var21.next(); @@ -579,6 +602,72 @@ public class MessageListen extends AbstractMessageServiceHandler { return requestBodyList; } + private List> getRequestBodyList3(HashMap map) { + String createDateString = ""; + String entityName = ""; + String startUserName = ""; + Long startUserId = null; + String taskName = ""; + Long userId = UserServiceHelper.getCurrentUserId(); + DynamicObject bos_user = BusinessDataServiceHelper.loadSingle(userId, "bos_user"); + String username = bos_user.getString("username"); + Long processInstanceId = Long.valueOf((String) map.get("processInstanceId")) ;//processInstanceId + QFilter proQF = new QFilter("processinstanceid", QCP.equals, processInstanceId); + DynamicObject processInstance = BusinessDataServiceHelper.loadSingle("wf_hitaskinst",proQF.toArray()); + if (processInstance != null) { + entityName = processInstance.getString("entityname"); + startUserId = processInstance.getLong("senderid"); + } + + if (startUserId != null) { + DynamicObject startUser = BusinessDataServiceHelper.loadSingle(startUserId, "bos_user"); + if (startUser != null) { + startUserName = startUser.getString("username"); + } + } + Date createDate = new Date(); + if (createDate != null) { + createDateString = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(createDate); + } + List> requestBodyList = new ArrayList(); + Map requestBody = new HashMap(); + + String syscodestr = System.getProperty("cxkg.integration.MessageListen.oakey"); + JSONObject jsonCode = JSON.parseObject(syscodestr); + String syscode = jsonCode.getString(entityName); + if(syscode == null || "".equals(syscode)){ + log.info("cxkg.integration.MessageListen.syscode is null: " + + entityName ); + } + + if(entityName != null && entityName.startsWith("差旅报销单")){ + entityName = "差旅报销单"; + } + String title = (String) map.get("title");//标题 + String url = (String) map.get("url");//processInstanceId + + + requestBody.put("syscode", syscode); + requestBody.put("flowid", String.valueOf(processInstanceId)); + requestBody.put("requestname", title); + requestBody.put("workflowname", entityName); // + "审批流程" + requestBody.put("nodename", taskName); + requestBody.put("pcurl", url + "&closeType=closeWin"); + requestBody.put("appurl", url != null ? getAppurl(url) : null); + requestBody.put("isremark", "2"); + requestBody.put("viewtype", "1"); + requestBody.put("creator", startUserName); + requestBody.put("createdatetime", createDateString); + requestBody.put("receiver", username); + requestBody.put("receivedatetime", createDateString); + requestBody.put("receivets", String.valueOf((new Date()).getTime())); + requestBody.put("userid", username); + requestBody.put("bizState", "0"); + requestBody.put("lastNameList", username); + requestBodyList.add(requestBody); + return requestBodyList; + } + // private String pushZHData(Map params) { // log.info("推送消息到中环....."); // Map registAppid = TokenAuthentication.registAppid(); diff --git a/shkd-cosmic-debug/src/main/java/shkd/plugin/ApprovalBillFormPlugin.java b/shkd-cosmic-debug/src/main/java/shkd/plugin/ApprovalBillFormPlugin.java index cdcb40d..0a59049 100644 --- a/shkd-cosmic-debug/src/main/java/shkd/plugin/ApprovalBillFormPlugin.java +++ b/shkd-cosmic-debug/src/main/java/shkd/plugin/ApprovalBillFormPlugin.java @@ -1,18 +1,27 @@ package shkd.plugin; +import kd.bos.dataentity.entity.DynamicObject; import kd.bos.form.plugin.AbstractFormPlugin; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.workflow.design.plugin.AbstractWorkflowPlugin; +import kd.bos.workflow.engine.msg.MessageService; +import kd.bos.workflow.engine.msg.cmd.MessageScheduleHelper; import kd.bos.workflow.taskcenter.plugin.ApprovalBillPlugin; import kd.bos.workflow.taskcenter.plugin.ApprovalBillViewPlugin; +import kd.imc.bdm.common.constant.BotpCallBackLogConstant; import kd.sdk.plugin.Plugin; +import kd.bos.workflow.engine.msg.info.MessageInfo; import org.agrona.Strings; +import shkd.cosmic.cxkg.integration.MessageListen; import java.util.EventObject; +import java.util.HashMap; import java.util.Map; /** * 审批单据界面插件 */ -public class ApprovalBillFormPlugin extends kd.bos.workflow.taskcenter.plugin.ApprovalBillViewPlugin { +public class ApprovalBillFormPlugin extends AbstractWorkflowPlugin { @Override @@ -21,8 +30,19 @@ public class ApprovalBillFormPlugin extends kd.bos.workflow.taskcenter.plugin.Ap Map customParams = this.getView().getFormShowParameter().getCustomParams(); String apptype = (String) customParams.get("apptype");//获取应用类型 String msgId = (String) customParams.get("msgId"); - if ("waver".equals(apptype) && Strings.isEmpty(msgId)){//当接口对象为泛微且提供消息对象主键不为空 - this.getView().showTipNotification("ce"+msgId); + Object processInstanceId = customParams.get("processInstanceId"); + if ("waver".equals(apptype) && !Strings.isEmpty(msgId) && processInstanceId != null){//当接口对象为泛微且提供消息对象主键不为空 + DynamicObject wf_msg_message = BusinessDataServiceHelper.loadSingle(msgId, "wf_msg_message");//获取消息模型对象 + HashMap map = new HashMap<>(); + if (wf_msg_message != null){ + map.put("processInstanceId",processInstanceId); + String title = wf_msg_message.getString("title");//标题 + map.put("title",title); + String contenturl = wf_msg_message.getString("contenturl");//url + map.put("url",contenturl); + } + MessageListen messageListen = new MessageListen(); + messageListen.sendMessage(map); } } } \ No newline at end of file