Commit 7e7af3a0 by 徐高华

企微托管

parent 6c3e50be
......@@ -141,7 +141,8 @@ public class QywxCallbackController extends WebBaseController {
// 14 101 图片
// 23 103(微信) 视频消息
// 15 102(微信) 文件消息
List<String> msgList = Arrays.asList("0","2","101","6","41","40","14","16","23","103","15","102") ;
//104 gif表情消息类型
List<String> msgList = Arrays.asList("0","2","101","6","41","40","14","16","23","103","15","102","104") ;
if(!msgList.contains(msgtype+"")) {
logger.info("不处理的消息");
return ;
......@@ -176,15 +177,15 @@ public class QywxCallbackController extends WebBaseController {
}else if(msgtype==23 || msgtype==103){
msg.setMsgtype(OpenQwMsgTypeEnum.VIDEO);
msg.setAeskey(json.getString("aes_key"));
}else if(msgtype==15 || msgtype==102){
msg.setMsgtype(OpenQwMsgTypeEnum.FILE);
msg.setAeskey(json.getString("aes_key"));
}else if(msgtype==6) {
msg.setMsgtype(OpenQwMsgTypeEnum.LOCAL);
msg.setContent(json.getString("address"));
}else if (msgtype==41) {
msg.setMsgtype(OpenQwMsgTypeEnum.NAME_CARD);
msg.setContent(json.getString("nickname"));
}else if (msgtype==15) {
msg.setMsgtype(OpenQwMsgTypeEnum.VIDEO);
msg.setContent(json.getString("nickname"));
}else if (msgtype==16) {
msg.setMsgtype(OpenQwMsgTypeEnum.VOICE);
msg.setContent(json.getString("语音消息"));
......
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONArray;
import org.apache.commons.lang3.StringUtils;
public class FileUtils {
public static void main(String[] args) {
System.out.println(JSONArray.parseArray(getText().toString()));
}
public static StringBuilder getText(){
StringBuilder list = new StringBuilder() ;
return list ;
}
}
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import org.apache.commons.lang3.StringUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import cn.hutool.crypto.SecureUtil;
public class FileUtils2 {
public static void main(String[] args) {
System.out.println(SecureUtil.md5("2af5e413ec4e44c29b4bab61021071ba" + "wmNYNmCgAA7AohTQh62UPdSKyr3m9bIg"));
/*String s = getText();
JSONArray jsonArr = JSONObject.parseObject(s).getJSONArray("value");
System.out.println(JSON.toJSONString(jsonArr));*/
}
public static String getText(){
try {
BufferedReader bw = new BufferedReader(new FileReader(new File("c:\\b.txt"))) ;
StringBuilder sb = new StringBuilder() ;
while(true) {
String s = bw.readLine() ;
if(StringUtils.isBlank(s)) {
break ;
}else {
String ss = new String(s.getBytes(),"UTF-8") ;
sb.append(ss) ;
}
}
bw.close();
return sb.toString() ;
}catch(Exception e) {
}
return null ;
}
}
import org.apache.commons.lang3.StringUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
public class FileUtils3 {
public static void main(String[] args) {
System.out.println(getText().get(0));
}
public static List<String> getText(){
List<String> list = new ArrayList<>();
try {
BufferedReader bw = new BufferedReader(new FileReader(new File("c:\\b.txt"))) ;
StringBuilder sb = new StringBuilder() ;
while(true) {
String s = bw.readLine() ;
if(StringUtils.isBlank(s)) {
break ;
}else {
String ss = new String(s.getBytes(),"UTF-8") ;
list.add(ss) ;
}
}
bw.close();
}catch(Exception e) {
}
return list ;
}
}
import org.apache.commons.lang3.StringUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
public class FileUtils4 {
public static String getText(){
try {
BufferedReader bw = new BufferedReader(new FileReader(new File("c:\\c.txt"))) ;
StringBuilder sb = new StringBuilder() ;
while(true) {
String s = bw.readLine() ;
if(StringUtils.isBlank(s)) {
break ;
}else {
String ss = new String(s.getBytes(),"UTF-8") ;
sb.append(ss) ;
}
}
bw.close();
return sb.toString() ;
}catch(Exception e) {
}
return null ;
}
}
import com.gic.api.base.commons.BasePageInfo;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.qdto.OpenStaffPageQDTO;
import com.gic.haoban.manage.api.service.HaobanTimerApiService;
import com.gic.haoban.manage.api.service.notify.NoticeMessageApiService;
import com.gic.haoban.manage.api.service.role.HaobanRoleApiService;
import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.service.service.OpenStaffService;
import com.gic.weimob.common.Md5Util;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"})
public class HalfFriendTest {
@Autowired
private OpenStaffService openStaffService ;
@Autowired
private NoticeMessageApiService noticeMessageApiService ;
@Test
public void tt() {
Map<String,String> map = new HashMap<>() ;
map.put("accountName","111222333111K") ;
map.put("errorTime","2024年4月20日 22:22") ;
map.put("reason","异常断开") ;
this.noticeMessageApiService.sendMessageForOpenStaff("ff8080815dacd3a2015dacd3ef5c0000","xgh","首次托管,需要二次验证");
/*OpenStaffPageQDTO qdto = new OpenStaffPageQDTO() ;
qdto.setWxEnterpriseId("ca66a01b79474c40b3e7c7f93daf1a3b");
qdto.setEnterpriseId("ff8080815dacd3a2015dacd3ef5c0000");
qdto.setClerkId("b2ef17cce11f476b996d0b27ebadf7fb");
qdto.setStoreGroupIdList(Arrays.asList("ff8080815dacd3a2015dacd3f4fc0033"));
qdto.setStaffParams("徐高华");
BasePageInfo basePageInfo = new BasePageInfo() ;
basePageInfo.setPageSize(11);
basePageInfo.setPageNum(1);
this.openStaffService.page(qdto,basePageInfo) ;*/
int messageType = NoticeMessageTypeEnum.HAOBAN_OPEN_STAFF_LOGOUT.getType();
// NoticeMessageUtil.sendNoticeMessageByStaff("ff8080815dacd3a2015dacd3ef5c0000","52995ea8c81c4cc286a9b82bc36a7081","-1",messageType,null,map,null);
}
}
import com.gic.haoban.manage.api.service.HaobanTimerApiService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.Arrays;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"})
public class HalfFriendTest123 {
@Autowired
private HaobanTimerApiService haobanTimerApiService ;
@Test
public void tt() {
List<String> list = Arrays.asList("27f6a5b4ed474c7889f9f35efdd90acb",
"c2a7904f682343efb9bc1cae026888a3",
"8477c149d8774f06ab841f042645832b") ;
for (String s : list) {
this.haobanTimerApiService.halfTimer(s);
}
}
}
import com.gic.haoban.manage.api.service.HaobanTimerApiService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.Arrays;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"})
public class HalfFriendTest333 {
@Autowired
private HaobanTimerApiService haobanTimerApiService ;
@Test
public void tt() {
List<String> list = Arrays.asList("93416e3a92504683b5b13513477a840a","369038a3568b46a6898d635843b73dc6","7f8c0c0eedd546ed9c4b355bb9cc2f31","9a7a89d2d1534c47980ea0886a202d3c") ;
for (String s : list) {
this.haobanTimerApiService.halfTimer(s);
}
}
}
import com.gic.haoban.manage.api.service.HaobanTimerApiService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.Arrays;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"})
public class HalfFriendTest444 {
@Autowired
private HaobanTimerApiService haobanTimerApiService ;
@Test
public void tt() {
List<String> list = Arrays.asList(
"727f05dbe66d48009719f63a189b9965",
"31060eb76d7a42969516c7ff12f9a1ea",
"703207906c5942b0937f8eda35036e9b",
"7a11c347030342eba50d188b96b646c0") ;
for (String s : list) {
this.haobanTimerApiService.halfTimer(s);
}
}
}
package log;
import lombok.Data;
import java.util.List;
@Data
public class EsResult {
private List<Hits> hits;
private String _scroll_id;
@Data
public static class Hits {
private List<Source> hits;
private Long total;
private Long totalNum;
}
@Data
public static class Total {
private Long value;
}
@Data
public static class Source {
private String _source;
}
@Data
public static class Message {
private String message;
}
}
package log;
import org.apache.http.impl.client.CloseableHttpClient;
/**
* 基于枚举的http单例
* @author jiaotianqi
* @date 2021/7/15 15:41
*/
public enum HttpClientEnum {
INITIALIZE;
private CloseableHttpClient httpClient = HttpClientInit.getHttpClient();
public CloseableHttpClient getHttpClient() {
return httpClient;
}
}
package log;
import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpRequest;
import org.apache.http.NoHttpResponseException;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.HttpHostConnectException;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.protocol.HttpContext;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLPeerUnverifiedException;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.util.concurrent.TimeUnit;
public class HttpClientInit {
/**
* 最大连接数
*/
public final static int MAX_TOTAL_CONNECTIONS = 1200;
/**
* 获取连接的最大等待时间
*/
public final static int WAIT_TIMEOUT = 30000;
/**
* 每个路由最大连接数
*/
public final static int MAX_ROUTE_CONNECTIONS = 400;
/**
* 连接超时时间
*/
public final static int CONNECT_TIMEOUT = 10000;
public static CloseableHttpClient getHttpClient() {
HttpRequestRetryHandler retryHandler = new HttpRequestRetryHandler() {
@Override
public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
if (executionCount >= 3) {
// Do not retry if over max retry count
return false;
}
if (exception instanceof InterruptedIOException) {
// Timeout
return true;
}
if (exception instanceof UnknownHostException) {
// Unknown host
return false;
}
if (exception instanceof ConnectTimeoutException) {
return true;
}
if (exception instanceof SSLException) {
return true;
}
if (exception instanceof SSLPeerUnverifiedException) {
// SSL handshake exception
System.out.println("https证书异常");
return true;
}
if (exception instanceof SocketTimeoutException) {
// SSL handshake exception
System.out.println("socket超时异常");
return true;
}
if (exception instanceof NoHttpResponseException) {
// SSL handshake exception
System.out.println("http无响应异常");
return true;
}
if (exception instanceof HttpHostConnectException) {
// SSL handshake exception
System.out.println("http主机连接异常");
return true;
}
HttpClientContext clientContext = HttpClientContext.adapt(context);
HttpRequest request = clientContext.getRequest();
boolean idempotent = !(request instanceof HttpEntityEnclosingRequest);
if (idempotent) {
return true;
}
return false;
}
};
RequestConfig requestConfig = RequestConfig.custom()
// 获取连接超时时间
.setConnectionRequestTimeout(CONNECT_TIMEOUT)
// 请求超时时间
.setConnectTimeout(CONNECT_TIMEOUT)
// 响应超时时间
.setSocketTimeout(CONNECT_TIMEOUT)
.build();
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setMaxTotal(MAX_TOTAL_CONNECTIONS);
cm.setDefaultMaxPerRoute(MAX_ROUTE_CONNECTIONS);
//单个路由设置其连接大小
//cm.setMaxPerRoute(new HttpRoute(new HttpHost("jd.com",80)), 100);
CloseableHttpClient httpClient = HttpClients.custom()
.setDefaultRequestConfig(requestConfig)
.setRetryHandler(retryHandler)
.setConnectionManager(cm)
//定期回收空闲连接
.evictExpiredConnections()
.setConnectionTimeToLive(1, TimeUnit.HOURS)
.build();
return httpClient;
}
}
package log;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import java.net.URI;
public class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase {
public static final String METHOD_NAME = "DELETE";
public String getMethod() {
return METHOD_NAME;
}
public HttpDeleteWithBody(final String uri) {
super();
setURI(URI.create(uri));
}
public HttpDeleteWithBody(final URI uri) {
super();
setURI(uri);
}
public HttpDeleteWithBody() {
super();
}
}
\ No newline at end of file
package log;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.gic.commons.util.DateUtil;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"})
public class KibanaLogDownload {
static KibanaLogDownload esQueryHelper = new KibanaLogDownload();
ObjectMapper objectMapper = new ObjectMapper();
private String indexName = "filebeat-6.7.2*";
private String ip = "http://10.0.2.11:9200";
private int skipTime = 1000 * 60 * 60 * 4;
public static KibanaLogDownload getInstance() {
return esQueryHelper;
}
public KibanaLogDownload setIndexName(String indexName) {
this.indexName = indexName;
return this;
}
public KibanaLogDownload setIp(String ip) {
this.ip = ip;
return this;
}
/**
* 游标查询
* @param param 参数
* @param time 失效时间
* @param consumer 单条回调
*/
public void postScroll(String param, String time, Consumer<String> consumer) {
EsResult res = null;
String htt = ip + "/" + indexName + "/_search?scroll=" + time;
String s = HttpClientUtil.postJson(htt, param, null);
String scrollId = null ;
try {
res = JSON.parseObject(s, EsResult.class);
scrollId = res.get_scroll_id();
for (EsResult.Hits hits2 : res.getHits()) {
for (EsResult.Source hit : hits2.getHits()) {
consumer.accept(hit.get_source());
}
}
boolean empty;
do {
empty=true;
String htt2 = ip + "/_search/scroll";
Map<String, String> pa = new HashMap<>();
pa.put("scroll", time);
pa.put("scroll_id", scrollId);
String s2 = HttpClientUtil.postJson(htt2, JSON.toJSONString(pa), null);
res = JSON.parseObject(s2, EsResult.class);
for (EsResult.Hits hits2 : res.getHits()) {
for (EsResult.Source hit : hits2.getHits()) {
empty=false;
consumer.accept(hit.get_source());
}
}
} while (!empty);
Map<String, String> pa = new HashMap<>();
pa.put("scroll_id", scrollId);
String clearScrollRes = HttpClientUtil.postDelJson(ip + "/_search/scroll/", JSON.toJSONString(pa), null);
System.out.println("游标清除1:"+clearScrollRes);
}catch (Exception e) {
e.printStackTrace();
if (null != scrollId) {
Map<String, String> pa = new HashMap<>();
pa.put("scroll_id", scrollId);
String clearScrollRes = HttpClientUtil.postDelJson(ip + "/_search/scroll/", JSON.toJSONString(pa), null);
System.out.println("游标清除2:"+clearScrollRes);
}
}
}
static int logCount = 0 ;
public static void main(String[] args) throws InterruptedException {
String startTime = "2024-05-08 19:00" ;
String endTime = "2024-05-08 22:00" ;
long start = DateUtil.strToDate(startTime,"yyyy-MM-dd HH:mm").getTime() ;
long end = DateUtil.strToDate(endTime,"yyyy-MM-dd HH:mm").getTime() ;
//long start = 1714446600000l ;
//long end = 1714448399999l ;
int size = 10000 ;
int batch = 1 ;
JSONArray arr = new JSONArray() ;
for(int i=0;i<batch;i++) {
long per = (end - start) / batch ;
long s1 = start+ (i)*per ;
long s2 = start+ (i+1)*per ;
System.out.println(s1 + " " + s2);
JSONObject root = JSONObject.parseObject("{}") ;
root.put("size",size) ;
JSONObject query = JSONObject.parseObject("{\"bool\":{\"must\":[{\"match_all\":{}},{\"bool\":{\"should\":[{\"match_phrase\":{\"message\":\"创蓝彩信回执=\"}}],\"minimum_should_match\":1}},{\"range\":{\"@timestamp\":{\"gte\":1715166000000,\"lte\":1715176800000,\"format\":\"epoch_millis\"}}}],\"filter\":[],\"should\":[],\"must_not\":[]}}") ;
root.put("query",query) ;
KibanaLogDownload.getInstance().postScroll(root.toJSONString(), "15m", source -> {
try {
//System.out.println(source + (logCount++));
//
// System.out.println((source.split("创蓝彩信回执=")[1]));
Pattern p = Pattern.compile("\\[.*\\]") ;
Matcher m = p.matcher(source.split("创蓝彩信回执=")[1]) ;
while(m.find()) {
String s = m.group() ;
// System.out.println(s);
JSONArray xx = JSONArray.parseArray(s.replace("\\",""));
// System.out.println(xx.toJSONString());
arr.addAll(xx) ;
}
}catch (Exception e) {
}
});
}
System.out.println(arr.toJSONString());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<import resource="classpath:gic-haoban-init.xml" />
<import resource="classpath*:redis-init.xml"/>
<import resource="classpath:dubbo-haoban-manage-service.xml" />
<import resource="classpath:dubbo-setting-test.xml"/>
<import resource="classpath:jdbc-haoban-manage-service.xml" />
<import resource="classpath*:log-record-init.xml" />
</beans>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment