bug
jiangqs
2023-08-21 c93e76c57a98e35abbf62d2f514d9ba51efd3243
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.ruoyi.system.util;
 
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
 
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
 
/**
 * @ClassName QiYeUtils
 * @Description TODO
 * @Author jqs
 * @Date 2023/7/18 19:07
 * @Version 1.0
 */
public class QiYeUtils {
 
    private final static String ACCESS_TOKEN_HOST = "https://qyapi.weixin.qq.com/cgi-bin/";
 
    public static void main(String[] args) throws Exception {
        Integer manTotal = 0;
        Integer womenTotal = 0;
        Integer personTotal = manTotal + womenTotal;
        BigDecimal manTotalBig = new BigDecimal(manTotal);
        BigDecimal personTotalBig = new BigDecimal(personTotal);
        BigDecimal bigTen = new BigDecimal("100.00");
        BigDecimal menPercent = new BigDecimal("100.00");
        BigDecimal womenPercent = new BigDecimal("100.00");
        if(manTotal==0&&womenTotal==0){
            menPercent = new BigDecimal("50.00");
            womenPercent = new BigDecimal("50.00");
        }else if(manTotal==0&&womenTotal>0){
            menPercent = new BigDecimal("0.00");
            womenPercent = new BigDecimal("100.00");
        }else if(manTotal>0&&womenTotal==0){
            menPercent = new BigDecimal("100.00");
            womenPercent = new BigDecimal("0.00");
        }else{
            menPercent = manTotalBig.divide(personTotalBig,2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
            womenPercent = bigTen.subtract(menPercent);
        }
        System.out.println(menPercent+"-"+womenPercent);
    }
 
    public static String getAccessTokenByQY() throws Exception {
        String host = ACCESS_TOKEN_HOST + "gettoken?corpid=ww11400938eb1b91bc&corpsecret=-wuQ2EBxNT9BJa40LdpFqyxI_8RqrZTCUNiabzBasi8";
        Map<String, String> headers = new HashMap<>(8);
        HttpResponse response = HttpUtils.doGet(host, "", "GET", headers, null);
        return EntityUtils.toString(response.getEntity());
    }
 
    public static String getDepartmentList(String accessToken) throws Exception {
        String host = ACCESS_TOKEN_HOST + "department/list?access_token="+accessToken;
        Map<String, String> headers = new HashMap<>(8);
        HttpResponse response = HttpUtils.doGet(host, "", "GET", headers, null);
        return EntityUtils.toString(response.getEntity());
    }
 
}