package com.chinaztt.mes.common.util; import com.alibaba.fastjson.JSON; import com.chinaztt.mes.common.wechat.servicemessagecustom.ServiceMessageCustom; import com.chinaztt.mes.common.wechat.servicemessagecustom.ServiceMessageCustomPortType; import java.util.*; /** * @Version 1.0 * @Author:xucg * @Date:2020-09-07 * @Content: */ public class WechatMsgTips { /** * 接口说明详细见 https://url.cn/kh0b1exG * * @param userList 接收人的账号List 账号是 ZT-027532 * @param content 传送内容 * @param title 标题 */ public static void sendOaNotice(List userList, String content, String title) { try { ServiceMessageCustom factory = new ServiceMessageCustom(); ServiceMessageCustomPortType wsImpl = factory.getServiceMessageCustomHttpPort(); Map map = new HashMap(); map.put("code", "1501"); map.put("title", title); map.put("context", content); Set list = new HashSet(userList); map.put("workCodeList", list); //接收人编号 第三种形式 参数是workCodeList //对应上面的四种形式,但是参数不变 boolean flag = wsImpl.sendCustomMessageSingle(JSON.toJSONString(map)); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { List usersList = new ArrayList<>(); usersList.add("ZT-038169"); WechatMsgTips. sendOaNotice(usersList, "大吉大利", "功能测试"); } }