109 lines
3.7 KiB
Java
109 lines
3.7 KiB
Java
package com.zhgd.xmgl.util;
|
||
|
||
import cn.hutool.http.HttpUtil;
|
||
import com.alibaba.fastjson.JSON;
|
||
import com.alibaba.fastjson.JSONArray;
|
||
import com.alibaba.fastjson.JSONObject;
|
||
import lombok.extern.slf4j.Slf4j;
|
||
import org.apache.commons.lang3.StringUtils;
|
||
|
||
import java.util.HashMap;
|
||
import java.util.Map;
|
||
import java.util.UUID;
|
||
|
||
/**
|
||
* @program: wisdomSite
|
||
* @description: 润德安全帽
|
||
* @author: Mr.Peng
|
||
* @create: 2021-10-22 19:33
|
||
**/
|
||
@Slf4j
|
||
public class RundeSafeyHatUtils {
|
||
|
||
private static String url = "https://caps.runde.pro/api/index.php";
|
||
|
||
// private static String user_name="广西中银金融中心";
|
||
// private static String pwd="123456";
|
||
|
||
public static String getPKey(String helmetUser, String helmetPassword) {
|
||
String token = null;
|
||
try {
|
||
Map<String, Object> param = new HashMap<>(16);
|
||
param.put("user_name", helmetUser);
|
||
param.put("pwd", helmetPassword);
|
||
param.put("ctl", "tool");
|
||
param.put("act", "get_pkey");
|
||
String result = HttpUtil.post(url, param);
|
||
if (StringUtils.isNotEmpty(result)) {
|
||
JSONObject object = JSONObject.parseObject(result);
|
||
String code = String.valueOf(object.get("status").toString());
|
||
if ("true".equals(code)) {
|
||
token = object.getString("data");
|
||
}
|
||
}
|
||
|
||
} catch (Exception e) {
|
||
log.error("error:", e);
|
||
}
|
||
return token;
|
||
}
|
||
|
||
public static JSONObject getToken(String helmetUser, String helmetPassword) {
|
||
JSONObject data = null;
|
||
try {
|
||
String token = getPKey(helmetUser, helmetPassword);
|
||
Map<String, Object> param = new HashMap<>(16);
|
||
param.put("user_name", helmetUser);
|
||
param.put("pkey", token);
|
||
param.put("ctl", "tool");
|
||
param.put("act", "get_token");
|
||
log.info("getToken:url:{},param:{}", url, JSON.toJSONString(param));
|
||
String result = HttpUtil.post(url, param);
|
||
log.info("getToken:rs:{}", result);
|
||
if (StringUtils.isNotEmpty(result)) {
|
||
JSONObject object = JSON.parseObject(result);
|
||
String code = String.valueOf(object.get("status").toString());
|
||
if ("true".equals(code)) {
|
||
object.put("userName", helmetUser);
|
||
data = object;
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
log.error("err", e);
|
||
}
|
||
return data;
|
||
}
|
||
|
||
public static JSONArray getGroupList(String adminId, String token) {
|
||
try {
|
||
Map<String, Object> param = new HashMap<>(16);
|
||
param.put("admin_id", adminId);
|
||
param.put("token", token);
|
||
param.put("udid", UUID.randomUUID().toString());
|
||
param.put("ctl", "bruce");
|
||
param.put("act", "get_group_list_v2");
|
||
String result = HttpUtil.post(url, param);
|
||
if (StringUtils.isNotEmpty(result)) {
|
||
JSONObject object = JSON.parseObject(result);
|
||
String code = String.valueOf(object.get("status").toString());
|
||
if ("true".equals(code)) {
|
||
JSONArray data = object.getJSONArray("data");
|
||
if (data == null) {
|
||
return new JSONArray();
|
||
}
|
||
return data;
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
log.error("error:", e);
|
||
}
|
||
return new JSONArray();
|
||
}
|
||
|
||
public static void main(String[] args) {
|
||
String s = UUID.randomUUID().toString();
|
||
System.out.println(s);
|
||
System.out.println(s.length());
|
||
}
|
||
}
|