bladex中服务远程调用

摘要:
//API接口//实现类//要调用的远程服务的接口//实现类别packageorg.springblade.flow.business.service。impl远程调用;importlombok。所有参数构造;导入流量任务pi。任务importorg.springblade.core.secure.utils.Auth

//api中接口

bladex中服务远程调用第1张

//实现类

bladex中服务远程调用第2张

bladex中服务远程调用第3张

//需要调用的远程服务的接口

bladex中服务远程调用第4张

bladex中服务远程调用第5张

//需要远程调用服务的实现类

bladex中服务远程调用第6张

bladex中服务远程调用第7张

package org.springblade.flow.business.service.impl;

import lombok.AllArgsConstructor;
import org.flowable.task.api.Task;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.flow.business.service.ISendWeChatMsg;
import org.springblade.resource.entity.WeChatSendMsgTextParam;
import org.springblade.resource.feign.IWeChatClient;
import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User;
import org.springframework.stereotype.Service;

import java.text.MessageFormat;
import java.util.List;
import java.util.Map;

import static org.springblade.core.launch.constant.FlowConstant.TASK_USR_PREFIX;

@Service
@AllArgsConstructor
public class SendWeChatMsg implements ISendWeChatMsg {

	private IWeChatClient weChatClient;

	@Override
	//发送消息
	public void sendWeChatMsg(List<Task> curTasks,List<Task> nextTasks,String msgType){
		if(Func.isEmpty(nextTasks)||Func.isNull(nextTasks)){
			return ;
		}
		Map<String, Object> map = nextTasks.get(0).getProcessVariables();
		String subject = "";
		String orderCode = "";
		String formName ="";
		if(Func.isNotEmpty(map)) {
			if (map.containsKey("subject")) {
				subject = map.get("subject").toString();
			}
			if (map.containsKey("orderCode")) {
				orderCode = map.get("orderCode").toString();
			}
			if (map.containsKey("formName")) {
				formName = map.get("formName").toString();
			}
		}
		String userId ="";
		String userName = "";
		if(Func.isNotEmpty(curTasks)) {
			Task task = curTasks.get(0);
			String assignee = task.getAssignee();
			if(Func.isNotEmpty(assignee)){
				if(assignee.contains(TASK_USR_PREFIX)){
					User fromUser = UserCache.getUserByTaskUser(assignee);
					if(Func.isNotEmpty(fromUser)) {
						userId = String.valueOf(fromUser.getId());
						userName = fromUser.getName();
					}
				}
				else if(Func.isNumeric(assignee)){
					userId = assignee;
					User user = UserCache.getUser(Long.valueOf(assignee));
					if(Func.isNotEmpty(user)){
						userName = user.getName();
					}
				}
				else {
					userId = String.valueOf(AuthUtil.getUserId());
					User user = UserCache.getUser(AuthUtil.getUserId());
					if(Func.isNotEmpty(user)){
						userName = user.getName();
					}
				}
			}
			else {
				userId = String.valueOf(AuthUtil.getUserId());
				User user = UserCache.getUser(AuthUtil.getUserId());
				if(Func.isNotEmpty(user)){
					userName = user.getName();
				}
			}
		}

		String weChatId ="";
		if(Func.isNotEmpty(nextTasks)) {
			for(Task task : nextTasks) {
				String assignee = task.getAssignee();
				if(Func.isNotEmpty(assignee)){
					if(assignee.contains(TASK_USR_PREFIX)){
						User toUser = UserCache.getUserByTaskUser(assignee);
						if(Func.isNotEmpty(toUser)) {
							if(Func.isNotEmpty(weChatId)){
								weChatId = weChatId+","+toUser.getWeChatId();
							}
							else{
								weChatId = toUser.getWeChatId();
							}
						}
					}
					else if(Func.isNumeric(assignee)){
						User toUser = UserCache.getUser(Long.valueOf(assignee));
						if(Func.isNotEmpty(toUser)){
							if(Func.isNotEmpty(weChatId)){
								weChatId = weChatId+","+toUser.getWeChatId();
							}
							else{
								weChatId = toUser.getWeChatId();
							}
						}
					}
				}
			}
		}

		if(Func.isNotEmpty(weChatId)){
			if("textCard".equals(msgType)){

			}
			else if("news".equals(msgType)){

			}
			else{
				//默认text
				WeChatSendMsgTextParam text = new WeChatSendMsgTextParam();
				String subjectFormat = "您有新接收的{0}代办事务,请处理: 主题 - {1} 单号 - {2} ";
				String content = MessageFormat.format(subjectFormat,formName,subject,orderCode);
				text.setTouser(weChatId);
				text.setContent(content);
				weChatClient.sendTextMsgFlow(userId,userName,subject,text);
			}
		}

	}

	@Override
	//发送消息
	public void sendWeChatMsg(String taskUser,List<Task> nextTasks,String msgType){
		if(Func.isEmpty(nextTasks)||Func.isNull(nextTasks)){
			return ;
		}
		Map<String, Object> map = nextTasks.get(0).getProcessVariables();
		String subject = "";
		String orderCode = "";
		String formName ="";
		if(Func.isNotEmpty(map)) {
			if (map.containsKey("subject")) {
				subject = map.get("subject").toString();
			}
			if (map.containsKey("orderCode")) {
				orderCode = map.get("orderCode").toString();
			}
			if (map.containsKey("formName")) {
				formName = map.get("formName").toString();
			}
		}
		String userId ="";
		String userName = "";
		if(Func.isNotEmpty(taskUser)) {
			String assignee = taskUser;
			if(Func.isNotEmpty(assignee)){
				if(assignee.contains(TASK_USR_PREFIX)){
					User fromUser = UserCache.getUserByTaskUser(assignee);
					if(Func.isNotEmpty(fromUser)) {
						userId = String.valueOf(fromUser.getId());
						userName = fromUser.getName();
					}
				}
				else if(Func.isNumeric(assignee)){
					userId = assignee;
					User user = UserCache.getUser(Long.valueOf(assignee));
					if(Func.isNotEmpty(user)){
						userName = user.getName();
					}
				}
				else {
					userId = String.valueOf(AuthUtil.getUserId());
					User user = UserCache.getUser(AuthUtil.getUserId());
					if(Func.isNotEmpty(user)){
						userName = user.getName();
					}
				}
			}
			else {
				userId = String.valueOf(AuthUtil.getUserId());
				User user = UserCache.getUser(AuthUtil.getUserId());
				if(Func.isNotEmpty(user)){
					userName = user.getName();
				}
			}
		}

		String weChatId ="";
		if(Func.isNotEmpty(nextTasks)) {
			for(Task task : nextTasks) {
				String assignee = task.getAssignee();
				if(Func.isNotEmpty(assignee)){
					if(assignee.contains(TASK_USR_PREFIX)){
						User toUser = UserCache.getUserByTaskUser(assignee);
						if(Func.isNotEmpty(toUser)) {
							if(Func.isNotEmpty(weChatId)){
								weChatId = weChatId+","+toUser.getWeChatId();
							}
							else{
								weChatId = toUser.getWeChatId();
							}
						}
					}
					else if(Func.isNumeric(assignee)){
						User toUser = UserCache.getUser(Long.valueOf(assignee));
						if(Func.isNotEmpty(toUser)){
							if(Func.isNotEmpty(weChatId)){
								weChatId = weChatId+","+toUser.getWeChatId();
							}
							else{
								weChatId = toUser.getWeChatId();
							}
						}
					}
				}
			}
		}

		if(Func.isNotEmpty(weChatId)){
			if("textCard".equals(msgType)){

			}
			else if("news".equals(msgType)){

			}
			else{
				//默认text
				WeChatSendMsgTextParam text = new WeChatSendMsgTextParam();
				String subjectFormat = "您有新接收的{0}代办事务,请处理: 主题 - {1} 单号 - {2} ";
				String content = MessageFormat.format(subjectFormat,formName,subject,orderCode);
				text.setTouser(weChatId);
				text.setContent(content);
				weChatClient.sendTextMsgFlow(userId,userName,subject,text);
			}
		}

	}

	@Override
	public void sendEndWeChatMsg(List<Task> curTasks, List<Task> nextTasks, String msgType) {
		if(Func.isEmpty(nextTasks)||Func.isNull(nextTasks)){
			return ;
		}
		Map<String, Object> map = nextTasks.get(0).getProcessVariables();
		String subject = "";
		String orderCode = "";
		String formName ="";
		String ccUser ="";
		if(Func.isNotEmpty(map)) {
			if (map.containsKey("subject")) {
				subject = map.get("subject").toString();
			}
			if (map.containsKey("orderCode")) {
				orderCode = map.get("orderCode").toString();
			}
			if (map.containsKey("formName")) {
				formName = map.get("formName").toString();
			}
			if (map.containsKey("ccUser")) {
				ccUser = map.get("ccUser").toString();
			}
		}
		String userId ="";
		String userName = "";
		if(Func.isNotEmpty(curTasks)) {
			String assignee = curTasks.get(0).getAssignee();
			if(Func.isNotEmpty(assignee)){
				if(assignee.contains(TASK_USR_PREFIX)){
					User fromUser = UserCache.getUserByTaskUser(assignee);
					if(Func.isNotEmpty(fromUser)) {
						userId = String.valueOf(fromUser.getId());
						userName = fromUser.getName();
					}
				}
				else if(Func.isNumeric(assignee)){
					userId = assignee;
					User user = UserCache.getUser(Long.valueOf(assignee));
					if(Func.isNotEmpty(user)){
						userName = user.getName();
					}
				}
				else {
					userId = String.valueOf(AuthUtil.getUserId());
					User user = UserCache.getUser(AuthUtil.getUserId());
					if(Func.isNotEmpty(user)){
						userName = user.getName();
					}
				}
			}
			else {
				userId = String.valueOf(AuthUtil.getUserId());
				User user = UserCache.getUser(AuthUtil.getUserId());
				if(Func.isNotEmpty(user)){
					userName = user.getName();
				}
			}
		}

		String weChatId ="";
		if(Func.isNotEmpty(ccUser)){
			String[] toTaskUserArray = Func.toStrArray(ccUser);
			for(int index = 0 ; index< toTaskUserArray.length;index++){
				String toTaskUser = toTaskUserArray[index];
				User toUser = null;
				if(toTaskUser.contains(TASK_USR_PREFIX)){
					toUser = UserCache.getUserByTaskUser(toTaskUser);
				}
				else if(Func.isNumeric(toTaskUser)) {
					toUser = UserCache.getUser(Long.valueOf(toTaskUser));
				}
				if(Func.isNotEmpty(toUser)&&Func.isNotEmpty(toUser.getWeChatId())) {
					if(Func.isNotEmpty(weChatId)){
						weChatId = weChatId+","+toUser.getWeChatId();
					}
					else{
						weChatId = toUser.getWeChatId();
					}
				}
			}
		}

		if(Func.isNotEmpty(weChatId)){
			if("textCard".equals(msgType)){

			}
			else if("news".equals(msgType)){

			}
			else{
				//默认text
				WeChatSendMsgTextParam text = new WeChatSendMsgTextParam();
				String subjectFormat = "您有新接收的{0}抄送事务,请处理: 主题 - {1} 单号 - {2} ";
				String content = MessageFormat.format(subjectFormat,formName,subject,orderCode);
				text.setTouser(weChatId);
				text.setContent(content);
				weChatClient.sendTextMsgFlow(userId,userName,subject,text);
			}
		}
	}

	@Override
	public void sendEndWeChatMsg(String taskUser, Map<String,Object> map, String msgType) {
		if(Func.isEmpty(map)||Func.isNull(map)){
			return ;
		}
		String subject = "";
		String orderCode = "";
		String formName ="";
		String ccUser ="";
		if(Func.isNotEmpty(map)) {
			if (map.containsKey("subject")) {
				subject = map.get("subject").toString();
			}
			if (map.containsKey("orderCode")) {
				orderCode = map.get("orderCode").toString();
			}
			if (map.containsKey("formName")) {
				formName = map.get("formName").toString();
			}
			if (map.containsKey("ccUser")) {
				ccUser = map.get("ccUser").toString();
			}
		}
		String userId ="";
		String userName = "";
		if(Func.isNotEmpty(taskUser)) {
			String assignee = taskUser;
			if(Func.isNotEmpty(assignee)){
				if(assignee.contains(TASK_USR_PREFIX)){
					User fromUser = UserCache.getUserByTaskUser(assignee);
					if(Func.isNotEmpty(fromUser)) {
						userId = String.valueOf(fromUser.getId());
						userName = fromUser.getName();
					}
				}
				else if(Func.isNumeric(assignee)){
					userId = assignee;
					User user = UserCache.getUser(Long.valueOf(assignee));
					if(Func.isNotEmpty(user)){
						userName = user.getName();
					}
				}
				else {
					userId = String.valueOf(AuthUtil.getUserId());
					User user = UserCache.getUser(AuthUtil.getUserId());
					if(Func.isNotEmpty(user)){
						userName = user.getName();
					}
				}
			}
			else {
				userId = String.valueOf(AuthUtil.getUserId());
				User user = UserCache.getUser(AuthUtil.getUserId());
				if(Func.isNotEmpty(user)){
					userName = user.getName();
				}
			}
		}

		String weChatId ="";
		if(Func.isNotEmpty(ccUser)){
			String[] toTaskUserArray = Func.toStrArray(ccUser);
			for(int index = 0 ; index< toTaskUserArray.length;index++){
				String toTaskUser = toTaskUserArray[index];
				User toUser = null;
				if(toTaskUser.contains(TASK_USR_PREFIX)){
					toUser = UserCache.getUserByTaskUser(toTaskUser);
				}
				else if(Func.isNumeric(toTaskUser)) {
					toUser = UserCache.getUser(Long.valueOf(toTaskUser));
				}
				if(Func.isNotEmpty(toUser)&&Func.isNotEmpty(toUser.getWeChatId())) {
					if(Func.isNotEmpty(weChatId)){
						weChatId = weChatId+","+toUser.getWeChatId();
					}
					else{
						weChatId = toUser.getWeChatId();
					}
				}
			}
		}

		if(Func.isNotEmpty(weChatId)){
			if("textCard".equals(msgType)){

			}
			else if("news".equals(msgType)){

			}
			else{
				//默认text
				WeChatSendMsgTextParam text = new WeChatSendMsgTextParam();
				String subjectFormat = "您有新接收的{0}抄送事务,请处理: 主题 - {1} 单号 - {2} ";
				String content = MessageFormat.format(subjectFormat,formName,subject,orderCode);
				text.setTouser(weChatId);
				text.setContent(content);
				weChatClient.sendTextMsgFlow(userId,userName,subject,text);
			}
		}
	}
}

免责声明:文章转载自《bladex中服务远程调用》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇解决Eclipse中更改HTML页面后,浏览器查看页面无变化Vue实例的的data对象下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

ABP 框架

ABP 框架基础知识 ABP是一个开源且文档友好的应用程序框架。ABP不仅仅是一个框架,它还提供了一个最徍实践的基于领域驱动设计(DDD)的体系结构模型,可以支持 .net framework和 .net core两种技术流派。 ABP 框架特点 依赖注入,这个部分使用 Castle windsor (依赖注入容器)来实现依赖注入,这个也是我们经常使用I...

前端调用api接口方法总结

我用得最多的大概就是jquery中的ajax了吧,就从ajax总结起走: 一、ajax: 参数解释:(主要就用到url、type、data、dataType、success、error等,其他的看需求而定) $.ajax({   url:" ", //请求的地址,类型为string type:" ", //请求方式,两种“get”或者“...

Selenium 4以后,再不相见的API

Selenium4前线快报中提到了Selenium 4的最新进展,伴随着Selenium 4各种功能的增强,最近的版本中也包含了一些旧API的更改和启用。如果你准备从Selenium 3升级到Selenium 4,那么最好留意这些更新。 文中所列的API,看样子要跟所有Seleniumer说再见了! 弃用DesiredCapabilities 在Selen...

微信小程序-获取当前城市位置

微信小程序-获取当前城市位置 , 在一些小程序,会根据不同的城市,展现不同的商品,和内容,这就需要获取位置,转换位城市来处理。     1, 获取当前地理位置,首先要拿到用户的授权wx.openSetting;        调起客户端小程序设置界面,返回用户设置的操作结果。设置界面只会出现小程序已经向用户请求过的权限 ,若没位置授权,则弹出。  2,微信...

k8s集群搭建学习-部署一个自定义java服务

一、创建docker镜像 dockerFile FROM openjdk:13 LABEL by=jty name=docker_boot description="k8s测试" version="v1.0" RUN mkdir -p /usr/local/k8s/ RUN cd /usr/local/k8s/ WORKDIR /usr/local/k...

ASP.NET Web API身份验证和授权

英语原文地址:http://www.asp.net/web-api/overview/security/authentication-and-authorization-in-aspnet-web-api 本文是作者所理解和翻译的内容。 这篇文章包括两部分:身份验证和授权。 身份验证用来确定一个用户的身份。例如,Alice用她的用户名和密码登陆系统,服务...