李林
2023-10-07 658d4927d468c47208fd012d9128b09249c07eff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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<String> userList, String content, String title) {
        try {
            ServiceMessageCustom factory = new ServiceMessageCustom();
            ServiceMessageCustomPortType wsImpl = factory.getServiceMessageCustomHttpPort();
            Map<String, Object> map = new HashMap();
            map.put("code", "1501");
            map.put("title", title);
            map.put("context", content);
            Set<String> 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<String> usersList = new ArrayList<>();
        usersList.add("ZT-038169");
        WechatMsgTips. sendOaNotice(usersList, "大吉大利", "功能测试");
    }
}