public static void doReport(Map<String, String> params) throws Exception { if (params != null) { String time = params.containsKey("time") ? params.get("time") : HawkTime.getTimeString(); String value = String.format( "'%s', '%s', '%s', '%s', '%s', '%s', %s, %s, %s, '%s', %s, %s, '%s', '%s'", params.get("game"), params.get("platform"), params.get("server"), CollectorServices.getChannelFromPuid(params.get("puid")), params.get("puid"), params.get("device"), params.get("playerid"), params.get("playerlevel"), params.get("changetype"), params.get("changeaction"), params.get("goldtype"), params.get("gold"), time, time.substring(0, 10)); String sql = String.format( "INSERT INTO gold(game, platform, server, channel, puid, device, playerid, playerlevel, changetype, changeaction, goldtype, gold, time, date) VALUES(%s);", value); DBManager.getInstance().executeSql(params.get("game"), sql); HawkLog.logPrintln("report_gold: " + value); } }
@Override @SuppressWarnings("unused") public void handle(HttpExchange httpExchange) throws IOException { try { String contentBody = HawkOSOperator.readRequestBody(httpExchange).replace("\r", ""); int pos = contentBody.indexOf("\n"); if (pos > 0) { int index = 0; String header = contentBody.substring(0, pos).trim(); String items[] = header.split("\\^"); if (items.length >= 7) { String md5 = ""; int stackPos = contentBody.indexOf("stack traceback"); if (stackPos > 0) { md5 = HawkMd5.makeMD5(contentBody.substring(stackPos)); } else { md5 = HawkMd5.makeMD5(contentBody); } if (logMd5Map.containsKey(md5)) { return; } logMd5Map.put(md5, md5); HawkLog.logPrintln("\r\nUserLog: " + contentBody); String game = items[index++]; String logtype = items[index++]; String platform = items[index++]; String serverid = items[index++]; String puid = items[index++]; String phoneinfo = items[index++]; String sysinfo = items[index++]; if (game.length() > 0 && logtype.length() > 0 && platform.length() > 0 && serverid.length() > 0 && puid.length() > 0) { // 创建日志目录 String dir = HawkOSOperator.getWorkPath() + "userlog/" + game + "/" + logtype + "/"; HawkOSOperator.createDir(dir); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd.HHmmss"); String tm = sdf.format(HawkTime.getDate()); String fileName = String.format("%s%s.%s.%s.%s", dir, platform, serverid, puid, tm); HawkOSOperator.saveAsFile(contentBody, fileName); } } } } catch (Exception e) { HawkException.catchException(e); } }