fix report

back_recharge
wangyuan 2019-09-26 13:44:35 +08:00
parent cf8066ae5c
commit 24c49c8cfe
2 changed files with 67 additions and 32 deletions

View File

@ -17,6 +17,7 @@ import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.network.server.ProtocolsManager;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.thread.task.DataReportTask;
import com.ljsd.jieling.thrift.idl.InvalidOperException;
import com.ljsd.jieling.thrift.idl.RPCRequestGMIFace;
import com.ljsd.jieling.thrift.idl.Result;
@ -24,11 +25,13 @@ import com.ljsd.jieling.util.*;
import org.apache.thrift.TException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.data.redis.core.ZSetOperations;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;
@ -44,6 +47,16 @@ public class GmService implements RPCRequestGMIFace.Iface {
GmInterface obj;
try {
if(cmd.contains("restartthread")){
Field configurableApplicationContextField = GameApplication.class.getDeclaredField("configurableApplicationContext");
configurableApplicationContextField.setAccessible(true);
ConfigurableApplicationContext configurableApplicationContext =(ConfigurableApplicationContext) configurableApplicationContextField.get(GameApplication.class);
DataReportTask bean = configurableApplicationContext.getBean(DataReportTask.class);
bean.start();
result.setResultCode(1);
return result;
}
if(cmd.contains("hotfix")){
List<User> usersInDB = MongoUtil.getLjsdMongoTemplate().findAll("user", User.class);
List<Integer> sendIds = new ArrayList<>(usersInDB.size());
@ -70,6 +83,7 @@ public class GmService implements RPCRequestGMIFace.Iface {
} catch (Exception ex) {
result.setResultMsg("Cmd Illegal");
ex.printStackTrace();
return result;
}
try {

View File

@ -1,7 +1,9 @@
package com.ljsd.jieling.config.reportData;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ljsd.GameApplication;
import com.ljsd.common.mogodb.util.BlockingUniqueQueue;
import com.ljsd.jieling.config.json.SDK37Constans;
@ -40,46 +42,65 @@ public class DataMessageUtils {
}
public static void manageData() {
List<Object> sendDataList = new ArrayList<>(10);
logQueue.drainTo(sendDataList, 10);
try {
List<Object> sendDataList = new ArrayList<>(10);
logQueue.drainTo(sendDataList, 10);
List<Object> sendData37List = new ArrayList<>(10);
logQueue_37.drainTo(sendData37List, 10);
List<Object> sendData37List = new ArrayList<>(10);
logQueue_37.drainTo(sendData37List, 10);
if (!sendDataList.isEmpty()) {
KTSendBody sendBody = new KTSendBody(sendDataList);
HttpPool.sendPost(sendUrl, gson.toJson(sendBody));
}
if (!sendDataList.isEmpty()) {
class ExclusionStrategy implements com.google.gson.ExclusionStrategy{
if (!sendData37List.isEmpty() && GameApplication.serverProperties.isSendlog37()) {
for (Object object : sendData37List) {
String sendToUrl;
List<BasicNameValuePair> sendForm = new ArrayList<>();
if (object instanceof Report37TaskBean) {
sendToUrl = sendTaskUrl37;
sendForm = ((Report37TaskBean) object).getPairList();
} else if (object instanceof Report37RoleLeveBean) {
sendToUrl = sendRoleUrl37;
sendForm = ((Report37RoleLeveBean) object).getPairList();
} else {
sendToUrl = "";
@Override
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
return "device_id_s".equals(fieldAttributes.getName()) && "ParamEnvironmentBean".equals(fieldAttributes.getDeclaringClass().getSimpleName());
}
@Override
public boolean shouldSkipClass(Class<?> aClass) {
return false;
}
}
Gson gson = new GsonBuilder()
.setExclusionStrategies(new ExclusionStrategy()) // <---
.create();
KTSendBody sendBody = new KTSendBody(sendDataList);
HttpPool.sendPost(sendUrl, gson.toJson(sendBody));
}
if (!sendData37List.isEmpty() && GameApplication.serverProperties.isSendlog37()) {
for (Object object : sendData37List) {
String sendToUrl;
List<BasicNameValuePair> sendForm = new ArrayList<>();
if (object instanceof Report37TaskBean) {
sendToUrl = sendTaskUrl37;
sendForm = ((Report37TaskBean) object).getPairList();
} else if (object instanceof Report37RoleLeveBean) {
sendToUrl = sendRoleUrl37;
sendForm = ((Report37RoleLeveBean) object).getPairList();
} else {
sendToUrl = "";
}
try {
HttpPool.sendPostForm(sendToUrl, new UrlEncodedFormEntity(sendForm, "utf-8"));
} catch (Exception e) {
}
}
}
if (sendDataList.isEmpty() && sendData37List.isEmpty()) {
try {
HttpPool.sendPostForm(sendToUrl, new UrlEncodedFormEntity(sendForm, "utf-8"));
} catch (Exception e) {
Thread.sleep(10);
return;
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
if (sendDataList.isEmpty() && sendData37List.isEmpty()) {
try {
Thread.sleep(10);
return;
} catch (InterruptedException e) {
e.printStackTrace();
}
}catch (Exception e){
e.printStackTrace();
}
}