report.mainReport.java Source code

Java tutorial

Introduction

Here is the source code for report.mainReport.java

Source

package report;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.sql.*;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.*;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.mail.internet.InternetAddress;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

public class mainReport {
    private static final String VERSION = "0.0.1";

    private static final String CONFIG_FILE = "report.conf";

    private static boolean SEND_EMAIL;

    // ------------------------------------------------------------------------
    // Replace keys found in target String with their corresponding values
    // Key format: ${key[:arg]}

    public static final char KEY_START_ESC = '\\';
    public static final String KEY_START = "${";
    public static final String KEY_END = "}";
    public static final String DFT_DELIM = "=";
    public static final String ARG_DELIM = ":";

    private static final String START_DELIM = KEY_START; // "${";
    private static final String END_DELIM = KEY_END; // "}";

    private static String MAIL_FROM;

    // ------------------------------------------------------------------------
    private static String url;
    private static String user;
    private static String password;
    private static String osrm;

    // ------------------------------------------------------------------------
    private static final Logger LOGGER = Logger.getLogger(Thread.currentThread().getStackTrace()[0].getClassName());
    static DecimalFormatSymbols formatSymbols = new DecimalFormatSymbols(Locale.getDefault());
    private static String[] deviceID;
    private static String[] deviceSpeedLimit;
    private static String date_trt;

    public static final char CSV_SEPARATOR_CHAR = '|';
    private static final double DISTANCE_MINI_ENTRE_POINT = 0.5D; //Distance en kilomtre
    private static boolean INTERPOLATION; //Distance en kilomtre
    private static final int ARRET_MAX = 600; //Dure maxi d'arrt 
    private static String TEMPLATE_NAME;
    private static int nbrarret = 0;
    private static String iconSpeed = "\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAYAAAAmL5yKAAAABmJLR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gkcBwODKrfn9ouaxsEOBfIH7v73+/MJm8tG9y8sudjx/no2lv02axsOX3ZyNe79eqogz8oKprQ0NDorxL5ff9/dUf7dhxqeT58+bijY0SAdZttrX4oUO//bK6+l339euRN/v/ALJlwVMJiV/BAAAAAElFTkSuQmCC\"";;
    private static String iconBegin = "\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAeCAYAAABE4bxTAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4AkaDh8W2zTybQAAANZJREFUWMPt1jFKA0EUBuBvk1QWgsFWEEkv6wW8SO4SDyAeIQfwCpb2jp1o6gRiEZEUCgmJRUbYQi3MLhF8D6aZ4s3HMO9niKpU0pa0q1utHSD2JZeSFyyxlIwkp1DUdMw1Jni2duXeEwa4xR7O0UcP3W+7lIpOTaBOXp/Xf4Thbxq1/tqzClCA6piOXdQCD5jm6DnOkdAAqPAumeGgknMrvGbEhdLNF4F51uQNHebeJ3jDGCul9Q+heNccaHPwAo8xZQEKUIACFKAABeifgGb5RzjfttEHRRIpVrvw4n4AAAAASUVORK5CYII=\"";
    //private static String iconEnd = "\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAeCAYAAADZ7LXbAAAACXBIWXMAAAsTAAALEwEAmpwYAAA/cmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMwNjcgNzkuMTU3NzQ3LCAyMDE1LzAzLzMwLTIzOjQwOjQyICAgICAgICAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOk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VudElEPgogICAgICAgICAgICA8c3RSZWY6b3JpZ2luYWxEb2N1bWVudElEPnhtcC5kaWQ6MDkxOUE3NjkwOTIwNjgxMTgyMkFFQ0Y5REQ2MzlEM0U8L3N0UmVmOm9yaWdpbmFsRG9jdW1lbnRJRD4KICAgICAgICAgPC94bXBNTTpEZXJpdmVkRnJvbT4KICAgICAgICAgPHBob3Rvc2hvcDpDb2xvck1vZGU+MzwvcGhvdG9zaG9wOkNvbG9yTW9kZT4KICAgICAgICAgPHRpZmY6T3JpZW50YXRpb24+MTwvdGlmZjpPcmllbnRhdGlvbj4KICAgICAgICAgPHRpZmY6WFJlc29sdXRpb24+NzIwMDAwLzEwMDAwPC90aWZmOlhSZXNvbHV0aW9uPgogICAgICAgICA8dGlmZjpZUmVzb2x1dGlvbj43MjAwMDAvMTAwMDA8L3RpZmY6WVJlc29sdXRpb24+CiAgICAgICAgIDx0aWZmOlJlc29sdXRpb25Vbml0PjI8L3RpZmY6UmVzb2x1dGlvblVuaXQ+CiAgICAgICAgIDxleGlmOkNvbG9yU3BhY2U+NjU1MzU8L2V4aWY6Q29sb3JTcGFjZT4KICAgICAgICAgPGV4aWY6UGl4ZWxYRGltZW5zaW9uPjI1PC9leGlmOlBpeGVsWERpbWVuc2lvbj4KICAgICAgICAgPGV4aWY6UGl4ZWxZRGltZW5zaW9uPjMwPC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgCjw/eHBhY2tldCBlbmQ9InciPz6mYouoAAAAIGNIUk0AAG2YAABzjgAA2ksAAIThAAB87gAA2AAAADI5AAAdLnSwtFsAAAITSURBVHja7NZPiE9RFAfwz33vzQyaGkqirEkjNv6sxEJSiqUFSklK+VeSsLRQoshKZGNhJSlRpElK1tggJYoZDCY/xm/m3WvhpZ/J+P1+k7Hh1K37ve+e9z3n3HvOPQHLcAz92IOB63mPtWGKEdGfkALnsbDCzzs5OCfkkgSr0DFG5+ZESN404BfX8h6LQ9fKeho9FFjzC537eIqtGG3y/6U4kuFytVBbGzqvrM6mnC5T2TcOASzHJtzDNmS/2DMVh3AL6wu8qj58XBe6MrLNpVGheRSW4Bz24WTDeg8OYHaFBwvkFcjfiZH0OjCjjZD3Vuc6nmQZPxkdTIJk/oL8J/lP8o+QXMTdCXJMbyRJ04VAmJu+45c4XJWNLVhRzc9hpA2SJwEbcQnve0Pe+7CYuUDSPSL2YWgcxXnYWVXh7t8Q7MeFRk+KR6ksT5W120J2NRufAB5jLxbhOL6MGTewAScw2OjJUGVh/6m82+7QjYSo3rxyzhqDB5oe/J7yk5XloJvpKzKdze/HwJjR2u26k+rWlB/sikMGRR2yCb8DTU08E7+YX77zINUVIZcmK0/epuhArIFOoW2iljP+RqrbUX4QQ2i7TLS1/2wc1heHFT/agkmqXdvjJy/SiI6QtRy2tkmepdLRWENo2Z8MXdV8WkN79PuwpWGX4md5KFryJmto7obwvlWPDsea/jSqaCF7vg0AWTWiZFCvq5oAAAAASUVORK5CYII=\"";
    private static String iconEnd = "\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAeCAYAAABE4bxTAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4AkaDiAAdz5tAAAAAIJJREFUWMPt1T0KgDAMhuG3Nuf3IB7MwUEQB11KXRQd/AEtKuULdGlK+hRCCoo1AsQAcbvnvkAc5Tw4S3RPBdRAQ6QMjuFuoSIRyOblnxYq/tZXAgmUHciSV3SMV0f8zkBeBqa9+Xp/8jMsOXv7YjW1QAIJJJBAAgmUKagFOqB/WmgCRD8SFoEdHLwAAAAASUVORK5CYII=\"";
    //private static String iconOne = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAABcSAAAXEgFnn9JSAAAAB3RJTUUH4AkaCzsPSHx54AAAAa9JREFUOMutlL9LG2Ecxj/3GjoVOrg4aCZLC3ZzUTD+AfIuhXKRWjopBecXXCqUDA5yuIYGnCRD3qEVeoN7wEHJLh2KmMEsDkqQJtzd2yHv4RnuLof1mZ/3eb8/nu/jkIDre2ipcH3vJbACrAOrQBkwwBXQBlpAW0vVj9/EcFLEXOAIeEE+hkBVS3WcFBVjYg37+yQxLOen63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83yWi1Y5h7ae8uS6f0fqR341R/RETRH+b+gGkUNya/YIzgiwwGFAFthG1ixHZSmJ3bwAFJhMjufta0FlwbaOr1mDcLDa5czg19DxffNvHawNc2cCy8avBh1e7rYhst/AKeg6/wErD8xQAAAABJRU5ErkJggg==\"";
    private static String iconTwo = "\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4AkbDx84vpzy8AAAAT1JREFUKM+Vkz1rAkEQhp89V08T0SKBBIIhoGksxEJb+zTaWPgD7IOQ+Cf8B1aCjdhekcpeEDsLwTKVESEKRk+92xRHLorfLwy7MO8zzLCzAj4fgHdQV1wkoUvgLRLxvObzASzrTExArfaDBAKFgn9aqUxDIM6Co1Evug4aoKXT6w/nKvgvoDaCjZxA1x2PBmBZzvmnev0GpR7daDZvice9Ox1o+9qazRSWhcpmR6NU6otczk+vd0c4rJ2GAZRStmF897vdJeXyBCEgk/GdBzsDeu9jMUmxeA2AYSy2DPIQKaXQlHp6BhiPbZLJ4a7nELxaKRKJIcGgxmCwZjKxz4dtG/r95dHJ9mZ8Pty3PCYJ4PGw1VO1OqPVMjm1cRKwOx35AnPX3G6btNvmxqZtyzSVC88bjUWoVApd/DF+ATDyaVs7xyMvAAAAAElFTkSuQmCC\"";
    private static String iconFree = "";
    private static String iconFor = "";
    private static String iconFive = "";
    private static String iconSix = "";
    private static String iconSeven = "";
    private static String iconEigth = "";
    private static String iconNine = "";
    private static String iconTen = "";
    private static String iconOnze = "";
    private static String iconDouze = "";
    private static String iconTreize = "";
    private static String iconQuatorze = "";
    private static String iconQuinze = "";
    private static String iconSeize = "";
    private static String iconDixsept = "";
    private static String iconDixhuit = "";
    private static String iconDixneuf = "";
    private static String iconVingt = "";
    private static String iconStopNOK = "\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4AkbDyEA11tREwAAATpJREFUKM+Vk79Lw0AUxz93ORM0Et0UpBSxruqga3dBdHFwcHBwF0Gd3f0PnAQdBMeincRVEAVRpFARCg6KFvxBkNbmziGhJhZD+uAt9+7zvvd+nDAHjGDYxNBHNyZxFIYN3Nwa+UXQQTZQCHjYQ2Ho1fmlD3m942FlVB0cA+kgEUjfnSmjACtyAwQxJxazAOkAoMJIINtZDVDch9HlX6XaEdxsw9sdiHjZHfUALR9MYPTZ/AvlacgtwNwt2AN/evavGd2slirUL+FqK8w6VMwKI5TNMF4BCqvhyWMpcUGloFKtmHEAGnU4mQr7IbLA+huOJ6CnHz6r0HxPgOkwGl4rYKctWUefAGm3Z5lmkbKlE6O634Xn09R3hbBBu/7FLK1oewCezkMXsQ1LVNSIYMGXrB16TK53/TF+AHB3WSqqgyLpAAAAAElFTkSuQmCC\"";
    private static String iconEvent = "\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4AkaEBcgyu9jhgAAAS5JREFUOMutk89Kw0AQxn/5WxQEofTYixffQPDqQwiCT+AzeFUQvHn27hPoSe/iM3hJBUOhIFoKaZiOh91ATHbTVjIwDLuZ/fb79ssErAkx5RhYRfBKHyHwKfDRBxACZwJq87QP0J8a4Kr2DP9id1MDq/Ky61zgA4tMLQmCGNVmSxpB6TobujYt2CMQo0pok+GwarnfVu5uXaYuFqqqKmlalz6WTRkCb39WRWHqclnffYg2ZHfYNELz3DBsG3QkayYCge8WYJapTqcuwMwr2RpxAuy1bisKyHMXj7HAeQvQ/nMh8OykP5/DZOITd+eTfOGQZHIwUEkS9X6HW2lMxH5Hs6qIMWU08vUsK6zQWn/daX1ph2I283UkAk8REAgcAO/0EzsxcAV8+eZ6y3j5BeUl49F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k/PlgGSuOeC1NvTTIW/cZ4IsKx3FvGys91L71kLHB5IRWlurePq13dkEjCvlraJSzD4BYrQTHM8Y+8utaOlEASutSCQq/pl/AtV0VeaZrneMcVNDSA0j+R4siaRBfPM680jcu6LpDFmrEQkbZWlPqBjh5GRwKOSE8XenCbAYny/wm0nW7EVgx9/YC2bEZlpUhzaPIzutuBpoY4KWHmOCY4g5OovHeTuoP7MXCBrQVRANb7wTQhHKaZOEUur2NsZpPM2QkaRkZZt7MG9BsQ2DZkMlmhDOyohv4BVicSNOeMzWwXVY+7CeytBTtL8HigogJqtjliEvhKoKQY+t/RIFGZK9EVesP1zhsoPo0ylnM0h14G0fAgsqP58bNNKBnhBQDxabY/e4j6gkgxJ8mOou+jKFCHdu9C+rVEIIYmPqGWcyQl6s35NGcG38PWKqfnHAoLIJUCryd/Y7YNfj8U+Vj15S0n3MDGGYvFaWQnX1AA9+9kSem/fqsNxWtheIQyt6DT62FTbw9sKF9c279gGDBjQfA5tF4gaEh4Zqe4/OQpe5JJ3IbByjCwDx3gUWEpp/4AwKortj+6uY4AAAAASUVORK5CYII=\"";

    public static void main(String[] args) throws IOException, ClassNotFoundException {
        // TODO Auto-generated method stub
        Connection con = null;
        Statement st = null;
        ResultSet rs = null;
        String sql = null;
        boolean flag = false;
        boolean sendmail = false;

        String accountID;

        String pathInfos = "";
        String stopsInfos = "";
        String eventsInfos = "";
        String secuInfos = "";
        //   <script type="text/javascript">
        //      stopsInfos[0] = Array(Array(Array(-18.14335, 49.38557, 20151208184519, "", null, 0)), "1273 TAM -WULLING");
        //   </script>
        String Infos = "";
        //new Array(new Array(null, stops[0], null), new Array(path[1], stops[1], events[1]), new Array(path[2], stops[2], events[2]), new Array(path[3], stops[3], events[3]), new Array(null, stops[4], null), new Array(path[5], stops[5], events[5]), new Array(null, stops[6], null))
        String gMapElts = "new Array(";
        String infoTab = "";
        //Food & Beverage - Compte-rendu du 08/12/2015
        String titre_date = "";
        String mail_to = "";
        String MAIL_SUBJECT = "";
        String MAIL_MESSAGE = "";
        int nbrdevice = 0;

        LinkedList<Events> pointsList;
        LinkedList<Events> pointsListnw;

        if (args.length == 0)
            accountID = "telo";
        else
            accountID = args[0];

        //File htmlTemplateFile = new File("d:\\template-V0.html");
        readConfig(CONFIG_FILE);
        File htmlTemplateFile = new File(TEMPLATE_NAME);
        String htmlString;
        htmlString = FileUtils.readFileToString(htmlTemplateFile);
        try {
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection(url, user, password);
            st = con.createStatement();
            pointsList = createTemporaryTable(con, st, accountID); //"FROM_UNIXTIME(dateEvt,'%d%m%Y%H%i%s') CREATE TEMPORARY TABLE datatmpEvt( accountID varchar(45), deviceID varchar(45), dateEvt Timestamp, lat double, lon double, speed int);";
            //calculTemp(con, st);
            //System.out.println("pointsList:" + pointsList.size());
            nbrdevice = deviceID.length;
            //System.out.println("Nombre de device: " + nbrdevice);
            for (int i = 0; i < deviceID.length; i++) {
                //pointsListnw = addpoints(accountID, deviceID[i], pointsList);
                //System.out.println("pointsList:" + pointsList.size()+" pointsListnw:" + pointsListnw.size());
                // Creation info du tableau
                infoTab = infoTab + createinfoTab(con, st, accountID, deviceID[i], i, pointsList);

                pathInfos = createpathInfos(con, st, deviceID[i], i, pointsList);
                if (pathInfos != null) {
                    pathInfos = "<script type=\"text/javascript\"> pathInfos[" + i + "] = " + pathInfos
                            + ";</script>";
                    Infos = Infos + pathInfos;
                    System.out.println(pathInfos);
                }
                stopsInfos = createstopsInfos(con, st, deviceID[i], i, pointsList);
                if (stopsInfos == null)
                    stopsInfos = createstopsInfosnull(con, st, accountID, deviceID[i]);
                if (stopsInfos != null) {
                    stopsInfos = "<script type=\"text/javascript\"> stopsInfos[" + i + "] = " + stopsInfos
                            + ";</script>";
                    Infos = Infos + stopsInfos;
                    System.out.println(stopsInfos);
                }
                eventsInfos = createeventsInfos(con, st, deviceID[i], i, pointsList);
                if (eventsInfos != null) {
                    eventsInfos = "<script type=\"text/javascript\"> eventsInfos[" + i + "] = " + eventsInfos
                            + ";</script>";
                    Infos = Infos + eventsInfos;
                    System.out.println(eventsInfos);
                }
                String pathElts = "path[" + i + "]";
                if (pathInfos == null)
                    pathElts = "null";
                String stopElts = "stops[" + i + "]";
                if (stopsInfos == null)
                    stopElts = "null";
                String eventsElts = "events[" + i + "]";
                if (eventsInfos == null)
                    eventsElts = "null";
                if (i > 0)
                    gMapElts = gMapElts + ", ";
                gMapElts = gMapElts + "new Array(" + pathElts + ", " + stopElts + ", " + eventsElts + ")";
                //System.out.println(Infos);
                secuInfos = secuInfos + createsecuInfos(deviceID[i], i, pointsList);
            }
            gMapElts = gMapElts + ")";
            //System.out.println(gMapElts);

            sql = "SELECT notifyEmail, allowNotify, suspendUntilTime FROM Account WHERE accountID='" + accountID
                    + "';";
            rs = st.executeQuery(sql);
            if (rs.next()) {
                mail_to = rs.getObject("notifyEmail") != null ? rs.getString("notifyEmail") : null;
                int allowNotify = rs.getObject("allowNotify") != null ? rs.getInt("allowNotify") : 0;
                int suspendUntilTime = rs.getObject("suspendUntilTime") != null ? rs.getInt("suspendUntilTime") : 0;
                if (mail_to != null && allowNotify > 0 && suspendUntilTime == 0) {
                    sendmail = true;
                }
            }
        } catch (SQLException ex) {
            LOGGER.severe(ex.getMessage());
        } finally {
            try {
                if (rs != null) {
                    rs.close();
                }
                if (st != null) {
                    st.close();
                }
                if (con != null) {
                    con.close();
                }

            } catch (SQLException ex) {
                LOGGER.warning(ex.getMessage());
            }
        }
        String title = "Araka";
        String filename = "";
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, -1);
        Date dateBefore1Days = cal.getTime();
        System.out.println(new SimpleDateFormat("dd/MM/yyyy").format(dateBefore1Days));
        date_trt = new SimpleDateFormat("dd/MM/yyyy").format(dateBefore1Days);
        String date_SpeedChart = new SimpleDateFormat("yyyy-MM-dd").format(dateBefore1Days);
        titre_date = accountID + " - Compte-rendu du " + date_trt;
        htmlString = htmlString.replace("$title", title);
        htmlString = htmlString.replace("$GAT_Infos", Infos);
        htmlString = htmlString.replace("$GAT_gMapElts", gMapElts);
        htmlString = htmlString.replace("$GAT_infoTab", infoTab);
        htmlString = htmlString.replace("$GAT_nbrdevice", Integer.toString(nbrdevice));
        htmlString = htmlString.replace("$GAT_Titre_date", titre_date);
        htmlString = htmlString.replace("$GAT_dateBegin", date_trt + " 00:00:00");
        htmlString = htmlString.replace("$GAT_dateEnd", date_trt + " 23:59:59");
        htmlString = htmlString.replace("$GAT_dateBSpeed", "\"" + date_SpeedChart + " 00:00:00\"");
        htmlString = htmlString.replace("$GAT_dateESpeed", "\"" + date_SpeedChart + " 23:59:59\"");
        htmlString = htmlString.replace("$GAT_secuInfos", secuInfos);
        htmlString = htmlString.replace("$GAT_iconSpeed", iconSpeed);
        htmlString = htmlString.replace("$GAT_60iconSpeed", iconSpeed60);
        htmlString = htmlString.replace("$GAT_65iconSpeed", iconSpeed65);
        htmlString = htmlString.replace("$GAT_70iconSpeed", iconSpeed70);
        htmlString = htmlString.replace("$GAT_iconBegin", iconBegin);
        htmlString = htmlString.replace("$GAT_iconEnd", iconEnd);
        htmlString = htmlString.replace("$GAT_iconOne", iconOne);
        htmlString = htmlString.replace("$GAT_iconTwo", iconOne);
        htmlString = htmlString.replace("$GAT_iconStopNOK", iconStopNOK);
        htmlString = htmlString.replace("$GAT_iconiconEvent", iconEvent);
        htmlString = htmlString.replace("$GAT_iconAccAlarm", iconAccAlarm);
        htmlString = htmlString.replace("$GAT_iconDecAlarm", iconDecAlarm);
        String datefile = new SimpleDateFormat("dd-MM-yyyy").format(dateBefore1Days);
        filename = accountID + "_COMPTE-RENDU_" + datefile + ".html";
        File newHtmlFile = new File(filename);
        FileUtils.writeStringToFile(newHtmlFile, htmlString);
        SendMail mail = new SendMail();
        try {
            if (sendmail && SEND_EMAIL) {
                MAIL_MESSAGE = "Compte: " + accountID + "\n";
                MAIL_MESSAGE = MAIL_MESSAGE + "Rapport: Parcours et Scurit du " + date_trt + " 00:00:00 au "
                        + date_trt + " 23:59:59";
                MAIL_SUBJECT = titre_date;
                mail.mailovh(MAIL_FROM, mail_to, MAIL_SUBJECT, MAIL_MESSAGE, filename);
            }

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public static String createinfoTab(Connection c, Statement s, String acId, String dvId, int irang,
            LinkedList pList) {
        // <tr>
        // <td>3</td> Rang
        // <td>113</td> Identif
        // <td>9114 TAN -JAC 3.5T</td> Info vhicule
        // <td>2015-12-08 06:59:07</td> date dbut
        // <td>2015-12-08 13:37:40</td> date fin
        // <td>00-00-00 02:15:34</td> roulage
        // <td>00-00-00 04:22:59</td> Arrt
        // <td>51</td> distance total
        // <td>22</td> vitesse moyenne
        // <td>79</td> Vitesse max
        // <td><input type="checkbox" style="cursor:pointer;" id="cb3"
        // title="Cliquez ici pour afficher le trajet de ce vhicule"
        // onclick="if (this.checked) {if (isReplayRunning)
        // pausePathReplay(true, true);if (curCheckedRowId > -1) {if (sb =
        // document.getElementById('sliderbg' + curCheckedRowId))
        // sb.style.display = 'none';if (cb = document.getElementById('cb' +
        // curCheckedRowId)) cb.title='Cliquez ici pour afficher le trajet de ce
        // vhicule';};gMapDisplayData(3, true, true,
        // false);secuDisplayData(3,true);curCheckedRowId=3;this.title='Cliquez
        // ici pour masquer le trajet de ce vhicule';}else
        // {pausePathReplay(true, true);if (sb =
        // document.getElementById('sliderbg' + 3)) sb.style.display =
        // 'none';pathFilterDiv.style.display = 'none';gMapHideData(3,
        // false);secuDisplayData(3,false);curCheckedRowId =
        // -1;this.title='Cliquez ici pour afficher le trajet de ce
        // vhicule';};"></td>
        // <input type="checkbox" style="cursor:pointer;" id="cb0"
        // title="Cliquez ici pour afficher le trajet de ce vhicule"
        // onclick="if (this.checked) {if (isReplayRunning)
        // pausePathReplay(true, true);if (curCheckedRowId > -1) {if (sb =
        // document.getElementById('sliderbg' + curCheckedRowId))
        // sb.style.display = 'none';if (cb = document.getElementById('cb' +
        // curCheckedRowId)) cb.title='Cliquez ici pour afficher le trajet de ce
        // vhicule';};gMapDisplayData(0, true, true,
        // false);secuDisplayData(0,true);curCheckedRowId=0;this.title='Cliquez
        // ici pour masquer le trajet de ce vhicule';}else {gMapHideData(0,
        // false);secuDisplayData(0,false);curCheckedRowId =
        // -1;this.title='Cliquez ici pour afficher le trajet de ce
        // vhicule';};">
        // <td>-18.93935 47.56441</td> coordonne evenement
        // </tr>
        boolean flag;
        ResultSet rs = null;
        int nb = 0;
        String infoTab = "";
        double odometreDeb = 0;
        double odometreFin = 0;
        double latitudemax = 0;
        double longitudemax = 0;
        double odometerKMlast = 0;
        double odometerOffsetKMlast = 0;
        double distance = 0;
        Timestamp dateEVlast = null, dateEVdeb = null;
        int speedmax = 0;
        int dureeroulage = 0;
        int dureearret = 0;

        formatSymbols.setDecimalSeparator('.');
        DecimalFormat dec = new DecimalFormat("#00.000000", formatSymbols);
        DecimalFormat deckms = new DecimalFormat("#0.0");
        infoTab = "<tr><td>" + irang + "</td><td>" + dvId + "</td>";
        String sql = "select accountID, deviceID, vehicleMake, vehicleModel, licensePlate FROM Device where accountID='"
                + acId + "' and deviceID='" + dvId + "';";
        try {
            rs = s.executeQuery(sql);
            if (rs.next()) {
                String vehicleMake = rs.getObject("vehicleMake") != null ? rs.getString("vehicleMake") : null;
                String vehicleModel = rs.getObject("vehicleModel") != null ? rs.getString("vehicleModel") : null;
                String licensePlate = rs.getObject("licensePlate") != null ? rs.getString("licensePlate") : null;
                infoTab = infoTab + "<td>" + licensePlate + " " + vehicleModel + "</td>";
            }
        } catch (SQLException ex) {
            LOGGER.severe(ex.getMessage());
        }
        distance = 0.0D;
        dureearret = 0;
        dureeroulage = 0;
        double duree = 0.;
        double vitessemoy = 0.0;
        int nbvitesse = 0;
        int nbreq = 0;
        int indpoint = 0;
        int ipoint = 0;
        int j = 0;
        String request = "";
        Events evtlast = null;

        for (int i = 0; i < pList.size(); i++) {
            Events evt = (Events) pList.get(i);
            if (evt.getDeviceID().equals(dvId)) {
                if (nb == 0) {
                    dateEVdeb = evt.getDateEvt();
                    request = request + "loc=" + dec.format(evt.getLatitude()) + ","
                            + dec.format(evt.getLongitude()); // point de dpart
                    nbreq++;
                }
                if (evt.getSpeed() > 0) {
                    if (i + 1 < pList.size()) {
                        duree = 0;
                        Events evtp = (Events) pList.get(i + 1);
                        if (evtp.getDeviceID().equals(dvId))
                            duree = (evtp.getDateEvt().getTime() - evt.getDateEvt().getTime()) / 1000.0;
                    }
                    dureeroulage = (int) (dureeroulage + duree); // Calcul temps de roulage
                    vitessemoy = vitessemoy + (int) evt.getSpeed();
                    nbvitesse++;
                } else {
                    duree = 0;
                    if (i + 1 < pList.size()) {
                        Events evtp = (Events) pList.get(i + 1);
                        if (evtp.getDeviceID().equals(dvId))
                            duree = (evtp.getDateEvt().getTime() - evt.getDateEvt().getTime()) / 1000.0;
                    }
                    dureearret = (int) (dureearret + duree); // Calcul temps d'arrt
                    //request = request + "loc=" + dec.format(evt.getLatitude()) + "," + dec.format(evt.getLongitude()); //pour le calcul de distance, en prend en compte que les arrts
                    nbreq++;
                }
                if (evt.getSpeed() > speedmax) {
                    speedmax = (int) evt.getSpeed();
                    latitudemax = evt.getLatitude();
                    longitudemax = evt.getLongitude();
                }
                if (evt.getSpeed() > evt.getSpeedMax()) { // Vrification vitesse maximum
                    request = request + "loc=" + dec.format(evt.getLatitude()) + ","
                            + dec.format(evt.getLongitude());
                    nbreq++;
                }
                dateEVlast = evt.getDateEvt();
                evtlast = evt;
                nb++;
            }
        }
        if (nb > 1) {
            request = request + "loc=" + dec.format(evtlast.getLatitude()) + ","
                    + dec.format(evtlast.getLongitude());
            nbreq++;
        }
        if (nbreq > 1) {
            request = osrm + request + "&instructions=false&alt=false";
            String rep = sendGet(request, "viaroute");
            double distcalc = Double.parseDouble(rep) / 1000.0;
            distance = distcalc;
            System.out.println("Distance: " + distcalc + " total: " + (int) distance + "kms" + " req:" + request);
        }

        if (nb > 1) {
            //System.out.println("Distance OSRM: " + deckms.format(distance));
            // distance = (odometerKMlast + odometerOffsetKMlast) - odometreDeb;
            //System.out.println("Distance: " + (int) distance + "kms");
            //System.out.println("Vitesse max: " + speedmax + "kms/h");
            //System.out.println("Temps roulage: " + (int) dureeroulage + "s");
            //double vitessemoy = distance / (dureeroulage / 3600.0);
            vitessemoy = vitessemoy / nbvitesse;
            //System.out.println("Vitesse moy: " + (int) vitessemoy + " kms/h");
            int numberOfDays;
            int numberOfHours;
            int numberOfMinutes;
            int numberOfSeconds;

            if (distance < 1) {
                vitessemoy = 0;
                speedmax = 0;
                dureeroulage = 0;
                dureearret = 0;
            }
            // numberOfDays = dureeroulage / 86400;
            numberOfHours = ((int) dureeroulage % 86400) / 3600;
            numberOfMinutes = (((int) dureeroulage % 86400) % 3600) / 60;
            numberOfSeconds = (((int) dureeroulage % 86400) % 3600) % 60;
            String roulage = numberOfHours + ":" + numberOfMinutes + ":" + numberOfSeconds;
            numberOfHours = ((int) dureearret % 86400) / 3600;
            numberOfMinutes = (((int) dureearret % 86400) % 3600) / 60;
            numberOfSeconds = (((int) dureearret % 86400) % 3600) % 60;
            String arret = numberOfHours + ":" + numberOfMinutes + ":" + numberOfSeconds;
            //System.out.println("Temps arrt: " + (int) dureearret + "s" + " " + arret);
            // long diff = dateEVlast.getTime() - dateEVdeb.getTime() ;
            // int dureeTH = (int) diff / 1000;
            // if (vitessemoy > 150) vitessemoy = 0;
            // System.out.println("Temps Total: " + dureeTH + "s");
            infoTab = infoTab + "<td>" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dateEVdeb.getTime())
                    + "</td>";
            infoTab = infoTab + "<td>" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dateEVlast.getTime())
                    + "</td>";
            infoTab = infoTab + "<td>00-00-00 " + roulage + "</td>";
            infoTab = infoTab + "<td>00-00-00 " + arret + "</td>";
            infoTab = infoTab + "<td>" + (int) distance + "</td>";
            infoTab = infoTab + "<td>" + (int) vitessemoy + "</td>";
            infoTab = infoTab + "<td>" + speedmax + "</td>";
            infoTab = infoTab + "<td><input type=\"checkbox\" style=\"cursor:pointer;\" id=\"cb" + irang
                    + "\" title=\"Cliquez ici pour afficher le trajet de ce v&eacute;hicule\" onclick=\"if (this.checked) {if (isReplayRunning) pausePathReplay(true, true);if (curCheckedRowId > -1) {if (sb = document.getElementById('sliderbg' + curCheckedRowId)) sb.style.display = 'none';if (cb = document.getElementById('cb' + curCheckedRowId)) cb.title='Cliquez ici pour afficher le trajet de ce v&eacutehicule';};gMapDisplayData("
                    + irang + ", true, true, false);secuDisplayData(" + irang + ",true);curCheckedRowId=" + irang
                    + ";this.title='Cliquez ici pour masquer le trajet de ce v&eacute;hicule';}else {pausePathReplay(true, true);if (sb = document.getElementById('sliderbg' + "
                    + irang + ")) sb.style.display = 'none';pathFilterDiv.style.display = 'none';gMapHideData("
                    + irang + ", false);secuDisplayData(" + irang
                    + ",false);curCheckedRowId = -1;this.title='Cliquez ici pour afficher le trajet de ce v&eacute;;hicule';};\"></td>";
            infoTab = infoTab + "<td>" + dec.format(latitudemax) + " " + dec.format(longitudemax) + "</td></tr>";
        } else {
            infoTab = infoTab + "<td></td><td></td><td></td><td></td><td>0</td><td>0</td><td>0</td>";
            infoTab = infoTab + "<td><input type=\"checkbox\" style=\"cursor:pointer;\" id=\"cb" + irang
                    + "\" title=\"Cliquez ici pour afficher le trajet de ce v&eacute;hicule\" onclick=\"if (this.checked) {if (isReplayRunning) pausePathReplay(true, true);if (curCheckedRowId > -1) {if (sb = document.getElementById('sliderbg' + curCheckedRowId)) sb.style.display = 'none';if (cb = document.getElementById('cb' + curCheckedRowId)) cb.title='Cliquez ici pour afficher le trajet de ce v&eacutehicule';};gMapDisplayData("
                    + irang + ", true, true, false);secuDisplayData(" + irang + ",true);curCheckedRowId=" + irang
                    + ";this.title='Cliquez ici pour masquer le trajet de ce v&eacute;hicule';}else {gMapHideData("
                    + irang + ", false);secuDisplayData(" + irang
                    + ",false);curCheckedRowId = -1;this.title='Cliquez ici pour afficher le trajet de ce v&eacute;hicule';};\"></td>";
            infoTab = infoTab + "<td></td></tr>";
        }
        //System.out.println("infoTab: " + infoTab);
        return infoTab;
    }

    public static String createstopsInfos(Connection c, Statement s, String dvId, int irang, LinkedList pList) {
        boolean flag;
        boolean first;
        ResultSet rs = null;
        String stopsInfos = "";
        String accountID = "";
        String deviceID = "";
        String deviceIDlast = "";
        Double latitude = 0.0;
        Double longitude = 0.0;
        Timestamp dateEV;
        Timestamp dateEVfirst, timestamp = null;
        String temps = "";
        String temps2 = "";
        String datem;
        int vitesse = 0;
        int tmps, nbstop = 0;
        int nb = 0, nblecture = 0;
        int indexlast = 0;
        double speedlast = -1;
        boolean havenext = false;
        String request = "";

        formatSymbols.setDecimalSeparator('.');
        DecimalFormat dec = new DecimalFormat("#00.000000", formatSymbols);

        nbrarret = 0;
        //stopsInfos[3]=Array(Array(Array(-18.94387,47.50355,20151208065907,"",null,0),Array(-18.93862,47.50042,70152,"00-00-00 00:03:20",70512,0)
        LinkedList<Events> pListemp = new LinkedList<Events>();
        for (int i = 0; i < pList.size(); i++) {
            Events evt = (Events) pList.get(i);
            if (evt.getDeviceID().equals(dvId)) {
                if (!(speedlast == 0 && evt.getSpeed() == 0)) {
                    pListemp.add(new Events(evt.getAccountID(), evt.DeviceID, evt.getLatitude(), evt.getLongitude(),
                            evt.getSpeed(), evt.getDateEvt(), evt.getOdometerKM(), evt.getOdometerOffsetKM(),
                            (int) evt.getStatusCode(), (int) evt.getSpeedMax(), evt.getHeading()));
                }
                speedlast = evt.getSpeed();
            }
        }
        for (int i = 0; i < pListemp.size(); i++) {
            Events evt = (Events) pListemp.get(i);
            if (i == 0) {
                stopsInfos = "Array(" + dec.format(evt.getLatitude()) + ", " + dec.format(evt.getLongitude()) + ", "
                        + new SimpleDateFormat("yyyyMMddHHmmss").format(evt.getDateEvt()) + ", \"\", null, "
                        + evt.getSpeed() + ")";
                accountID = evt.getAccountID();
                speedlast = evt.getSpeed();
                indexlast = i;
                nbstop++;
                request = request + "loc=" + dec.format(evt.getLatitude()) + "," + dec.format(evt.getLongitude());
            } else {
                if (evt.getSpeed() < 1.) {
                    tmps = getDuration(pListemp, dvId, i);
                    if (i == (indexlast + 1) && speedlast < 1) {
                    } else {
                        if (tmps > ARRET_MAX) {
                            temps = "\"00-00-00 " + getDurationString(tmps) + "\"";
                            Calendar cal = Calendar.getInstance();
                            cal.setTimeInMillis(evt.getDateEvt().getTime());
                            cal.add(Calendar.SECOND, tmps);
                            timestamp = new Timestamp(cal.getTime().getTime());
                            temps2 = new SimpleDateFormat("HHmmss").format(timestamp);
                            datem = new SimpleDateFormat("HHmmss").format(evt.getDateEvt());

                            stopsInfos = stopsInfos + ", Array(" + dec.format(evt.getLatitude()) + ", "
                                    + dec.format(evt.getLongitude()) + ", " + datem + ", " + temps + ", " + temps2
                                    + ", " + evt.getSpeed() + ")";
                            nbstop++;
                            nbrarret++;
                            indexlast = i;
                            //request = request + "loc=" + dec.format(evt.getLatitude()) + "," + dec.format(evt.getLongitude());
                        }
                    }
                }
                speedlast = evt.getSpeed();
            }
        }
        if (pListemp.size() > 2 && indexlast != (pListemp.size() - 1)) {
            Events evt = (Events) pListemp.get(pListemp.size() - 1);
            stopsInfos = stopsInfos + ", Array(" + dec.format(evt.getLatitude()) + ", "
                    + dec.format(evt.getLongitude()) + ", "
                    + new SimpleDateFormat("yyyyMMddHHmmss").format(evt.getDateEvt()) + ", \"\", null, "
                    + evt.getSpeed() + ")";
            //request = request + "loc=" + dec.format(evt.getLatitude()) + "," + dec.format(evt.getLongitude());
        }
        //System.out.println("stopsInfos Dernier points: "+stopsInfos);

        if (nbstop > 0) {
            /*if (nbstop > 1){
               Events evt = (Events) pList.get(indexlast);
               stopsInfos = stopsInfos + ", Array(" + dec.format(evt.getLatitude())+", "+ dec.format(evt.getLongitude())+", "+new SimpleDateFormat("yyyyMMddHHmmss").format(evt.getDateEvt())+", \"\", null, "+evt.getSpeed()+")";
               nbstop++;
            }*/
            stopsInfos = stopsInfos + ")";
            String sql = "SELECT accountID, deviceID, vehicleMake, vehicleModel, licensePlate FROM Device where accountID='"
                    + accountID + "' and deviceID='" + dvId + "';";
            try {
                rs = s.executeQuery(sql);
                if (rs.next()) {
                    String vehicleMake = rs.getObject("vehicleMake") != null ? rs.getString("vehicleMake") : null;
                    String vehicleModel = rs.getObject("vehicleModel") != null ? rs.getString("vehicleModel")
                            : null;
                    String licensePlate = rs.getObject("licensePlate") != null ? rs.getString("licensePlate")
                            : null;
                    stopsInfos = "Array(Array(" + stopsInfos + ", \"" + licensePlate + " " + vehicleModel + "\")";

                }
                rs.close();
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            //System.out.println("stopsInfos: "+nbstop);
            //System.out.println(stopsInfos);
        } else {
            stopsInfos = null;
            System.out.println(deviceIDlast + " AUCUN stopsInfos");
        }
        return stopsInfos;
    }

    public static String createstopsInfosnull(Connection c, Statement s, String acId, String dvId) {
        ResultSet rs = null;
        String stopsInfos = "";

        formatSymbols.setDecimalSeparator('.');
        DecimalFormat dec = new DecimalFormat("#00.000000", formatSymbols);
        String sql = "SELECT accountID, FROM_UNIXTIME(timestamp) as timestamp, deviceID, latitude, longitude, speedKPH FROM EventData WHERE accountID='"
                + acId + "' AND deviceID='" + dvId + "' AND longitude >0.0 ORDER BY timestamp DESC LIMIT 1;";
        try {
            rs = s.executeQuery(sql);
            if (rs.next()) {
                stopsInfos = "Array(";
                int speedKPH = rs.getObject("speedKPH") != null ? rs.getInt("speedKPH") : null;
                Timestamp dateEV = rs.getTimestamp("timestamp");
                double latitude = rs.getObject("latitude") != null ? rs.getDouble("latitude") : null;
                double longitude = rs.getObject("longitude") != null ? rs.getDouble("longitude") : null;
                stopsInfos = stopsInfos + "Array(" + dec.format(latitude) + ", " + dec.format(longitude) + ", "
                        + new SimpleDateFormat("yyyyMMddHHmmss").format(dateEV) + ", \"\", null, 0))";
                sql = "SELECT accountID, deviceID, vehicleMake, vehicleModel, licensePlate FROM Device where accountID='"
                        + acId + "' and deviceID='" + dvId + "';";
                ResultSet rs1 = s.executeQuery(sql);
                if (rs1.next()) {
                    String vehicleMake = rs1.getObject("vehicleMake") != null ? rs1.getString("vehicleMake") : null;
                    String vehicleModel = rs1.getObject("vehicleModel") != null ? rs1.getString("vehicleModel")
                            : null;
                    String licensePlate = rs1.getObject("licensePlate") != null ? rs1.getString("licensePlate")
                            : null;
                    stopsInfos = "Array(" + stopsInfos + ", \"" + licensePlate + " " + vehicleModel + "\")";
                }
                rs1.close();
            }
            rs.close();
            System.out.println(dvId + " stopsInfosnull");
            //System.out.println(stopsInfos);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return stopsInfos;
    }

    public static String createpathInfos(Connection c, Statement s, String dvId, int irang, LinkedList pList) {
        boolean flag, first;
        ResultSet rs = null;
        String accountID = "";
        String deviceID = "";
        String deviceIDlast = "";
        Double latitude = 0.0;
        Double longitude = 0.0;
        Timestamp dateEV = null;
        String dateEVbegin = "";
        String dateEVend = "";
        String datem;
        int vitesse = 0;
        int tmps, nbpath = 0;
        int nb = 0;
        String pathinfos = "";
        int indexbegin = 0, indexend = 0;

        formatSymbols.setDecimalSeparator('.');
        DecimalFormat dec = new DecimalFormat("#00.000000", formatSymbols);
        for (int i = 0; i < pList.size(); i++) {
            Events evt = (Events) pList.get(i);
            accountID = evt.getAccountID();
            if (evt.getDeviceID().equals(dvId)) {
                int k = i + 1;
                tmps = 0;
                if (k < pList.size()) {
                    Events evtnxt = (Events) pList.get(k);
                    if (evtnxt.getDeviceID().equals(dvId)) {
                        double diff = evtnxt.getDateEvt().getTime() - evt.getDateEvt().getTime();
                        tmps = (int) diff / 1000;
                    }
                }
                if (nbpath == 0) {
                    pathinfos = "Array(";
                    dateEVbegin = new SimpleDateFormat("yyyMMddHHmmss").format(evt.getDateEvt());
                    datem = new SimpleDateFormat("yyyyMMddHHmmss").format(evt.getDateEvt());
                    indexbegin = i;
                } else {
                    datem = new SimpleDateFormat("HHmmss").format(evt.getDateEvt());
                    pathinfos = pathinfos + ", ";
                }
                pathinfos = pathinfos + "Array(" + dec.format(evt.getLatitude()) + ", "
                        + dec.format(evt.getLongitude()) + ", " + datem + ", " + evt.getHeading() + ", "
                        + (int) evt.getSpeed() + ")";
                nbpath++;
                dateEVend = new SimpleDateFormat("yyyMMddHHmmss").format(evt.getDateEvt());
                indexend = i;
            }
        }
        Events evt = (Events) pList.get(indexbegin);
        Events evtnxt = (Events) pList.get(indexend);
        int distance = (int) (evtnxt.getOdometerKM() - evt.getOdometerKM());

        if (nbpath > 1 && distance > 1) {
            pathinfos = pathinfos + ")";
            String sql = "SELECT accountID, deviceID, vehicleMake, vehicleModel, licensePlate FROM Device where accountID='"
                    + accountID + "' and deviceID='" + dvId + "';";
            try {
                rs = s.executeQuery(sql);
                if (rs.next()) {
                    String vehicleMake = rs.getObject("vehicleMake") != null ? rs.getString("vehicleMake") : null;
                    String vehicleModel = rs.getObject("vehicleModel") != null ? rs.getString("vehicleModel")
                            : null;
                    String licensePlate = rs.getObject("licensePlate") != null ? rs.getString("licensePlate")
                            : null;
                    pathinfos = "Array(" + pathinfos + ", \"" + dateEVbegin + "\", \"" + dateEVend + "\", 1)";

                }
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            System.out.println("Nb de points path: " + nbpath);
            System.out.println(pathinfos);
        } else {
            pathinfos = null;
            System.out.println(deviceIDlast + " AUCUN pathInfos");
        }
        return pathinfos;
    }

    public static String createeventsInfos(Connection c, Statement s, String dvId, int irang, LinkedList pList) {
        boolean flag;
        ResultSet rs = null;
        String eventsInfos = "";
        String accountID = "";
        String deviceID = "";
        String deviceIDlast = "";
        Double latitude = 0.0;
        Double longitude = 0.0;
        float vitesse = 0;
        String accountIDlast = "";
        Double latitudelast = 0.0;
        Double longitudelast = 0.0;
        Timestamp dateEVlast = null;
        int speed, speedmax = 0, nbevents = 0;
        int dureepararret = 0;
        int nbrdepvitesse = 0;
        int dureedepvitesse = 0;

        formatSymbols.setDecimalSeparator('.');
        DecimalFormat dec = new DecimalFormat("#00.000000", formatSymbols);
        speedmax = 0;
        for (int i = 0; i < pList.size(); i++) {
            Events evt = (Events) pList.get(i);
            if (evt.getDeviceID().equalsIgnoreCase(dvId)) {
                accountID = evt.getAccountID();
                deviceID = evt.getDeviceID();
                if (speedmax < evt.getSpeed()) {
                    speedmax = (int) evt.getSpeed();
                    latitudelast = evt.getLatitude();
                    longitudelast = evt.getLongitude();
                    dateEVlast = evt.getDateEvt();
                }
                if (evt.getSpeed() > evt.getSpeedMax()) { // Vrification vitesse maximum
                    nbrdepvitesse++;
                    if (nbevents == 0) {
                        eventsInfos = "Array(";
                    } else
                        eventsInfos = eventsInfos + ", ";
                    int limit = 60;
                    if (evt.getSpeed() > 65)
                        limit = 65;
                    if (evt.getSpeed() > 70)
                        limit = 70;

                    eventsInfos = eventsInfos + "Array(" + dec.format(evt.getLatitude()) + ", "
                            + dec.format(evt.getLongitude()) + ", "
                            + new SimpleDateFormat("yyyyMMddHHmmss").format(evt.getDateEvt()) + ", "
                            + new SimpleDateFormat("HHmmss").format(evt.getDateEvt())
                            + ",\"\", \"Vitesse maximale\", " + evt.getSpeed() + ", " + limit + ")";
                    nbevents++;
                }
            }
        }
        if (speedmax > 0) {
            if (nbevents == 0) {
                eventsInfos = "Array(";
            } else
                eventsInfos = eventsInfos + ", ";
            //Array(Array(-18.94375, 47.50367, 20151208070953, 289, 0), Array(-18.94341, 47.50208, 71013, 309, 32))

            eventsInfos = eventsInfos + "Array(" + dec.format(latitudelast) + ", " + dec.format(longitudelast)
                    + ", " + new SimpleDateFormat("yyyyMMddHHmmss").format(dateEVlast) + ", "
                    + new SimpleDateFormat("HHmmss").format(dateEVlast) + ",\"\", \"Vitesse maximale\", " + speedmax
                    + ", -2" + ")";
            nbevents++;
        }

        if (nbevents > 0) {
            eventsInfos = eventsInfos + ")";

            String sql = "SELECT accountID, deviceID, vehicleMake, vehicleModel, licensePlate FROM Device where accountID='"
                    + accountID + "' and deviceID='" + deviceID + "';";
            try {
                rs = s.executeQuery(sql);
                if (rs.next()) {
                    String vehicleMake = rs.getObject("vehicleMake") != null ? rs.getString("vehicleMake") : null;
                    String vehicleModel = rs.getObject("vehicleModel") != null ? rs.getString("vehicleModel")
                            : null;
                    String licensePlate = rs.getObject("licensePlate") != null ? rs.getString("licensePlate")
                            : null;
                    eventsInfos = "Array(" + eventsInfos + ", \"" + licensePlate + " " + vehicleModel + "\")";

                }
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            System.out.println(deviceIDlast + " eventsInfos");
            //System.out.println(eventsInfos);
        } else {
            eventsInfos = null;
            System.out.println(deviceIDlast + " AUCUN eventsInfos");
        }
        return eventsInfos;
    }

    public static String createsecuInfos(String dvId, int irang, LinkedList pList) {
        String secuInfos = "";
        int nbinfo = 0;
        int nbrdepvitesse = 0;

        for (int i = 0; i < pList.size(); i++) {
            Events evt = (Events) pList.get(i);
            if (evt.getDeviceID().equalsIgnoreCase(dvId)) {
                /*if (evt.getSpeed() < 1 ){ // Vrification nombre d'arrt
                   int tmps = getDuration(pList, dvId, i);
                  if (tmps > ARRET_MAX){
                  nbrarret ++;
                  nbinfo ++;
                  }
                }  */
                if (evt.getSpeed() > evt.getSpeedMax()) { // Vrification vitesse maximum
                    nbrdepvitesse++;
                    nbinfo++;
                }
            }
        }
        if (nbinfo > 0) {
            //nbrarret = nbrarret - 2; //On enlve le point de dpart et d'arriv
            if (nbrarret < 1)
                nbrarret = 0;
            secuInfos = secuInfos + "<div id=\"secu" + irang + "\" class=\"secuInfos\"><img id=\"imgEvent" + irang
                    + "\" class=\"siCatIcon\"/><label class=\"siLabel\">Ev&egrave;nements";
            secuInfos = secuInfos
                    + "</label><hr /><br /><table><tr><td><table class=\"alignToChart tableSecuInfos\"><tr><td class=\"tsiLabel\">Nombre total d'arr&ecirc; ts</td>";
            secuInfos = secuInfos + "<td class=\"tsiData\">" + nbrarret + "</td></tr>"
                    + "<tr><td class=\"tsiLabel\">Nombre d'arr&ecirc; ts non-autoris&eacute;s</td><td class=\"tsiData\">0</td></tr></table>"
                    + "</td><td><img id=\"secTabImgLegendStopOK" + irang
                    + "\" class=\"secTabLegendImgAlt\"></td></tr></table><br /><table><tr><td>";
            secuInfos = secuInfos + "<table class=\"alignToChart tableSecuInfos\"><tr>"
                    + "<td class=\"tsiLabel\">Nombre total de d&eacute;passements de vitesse</td><td class=\"tsiData\">"
                    + nbrdepvitesse + "</td></tr>"
                    + "<tr><td class=\"tsiLabel\">Dur&eacute;e totale en d&eacute;passement de vitesse</td><td class=\"tsiData\">00:00:00</td></tr><tr><td class=\"tsiLabel\">D&eacute;passements de vitesse / dur&eacute;e de roulage</td><td class=\"tsiData\">0.0%</td></tr></table></td><td>";
            secuInfos = secuInfos + "<img id=\"secTabImgLegendSpeed" + irang
                    + "\" class=\"secTabLegendImg\"></td></tr></table><br /><table><tr><td>"
                    + "<table class=\"alignToChart tableSecuInfos\"><tr><td class=\"tsiLabel\">Nombre d'acc&eacute;l&eacute;rations hors-norme</td>"
                    + "<td class=\"tsiData\">0</td></tr><tr><td class=\"tsiLabel\">Dur&eacute;e en acc&eacute;l&eacute;ration hors-norme</td><td class=\"tsiData\">00:00:00</td></tr>"
                    + "<tr><td class=\"tsiLabel\">Acc&eacute;l&eacute;rations hors-norme / dur&eacute;e de roulage</td><td class=\"tsiData\">0.0%</td></tr></table></td><td><img id=\"secTabImgAccAlarm"
                    + irang + "\" class=\"secTabLegendImg\"></td></tr></table><br />";
            secuInfos = secuInfos
                    + "<table><tr><td><table class=\"alignToChart tableSecuInfos\"><tr><td class=\"tsiLabel\">Nombre de d&eacute;c&eacute;l&eacute;rations hors-norme</td><td class=\"tsiData\">0</td>"
                    + "</tr><tr><td class=\"tsiLabel\">Dur&eacute;e en d&eacute;c&eacute;l&eacute;ration hors-norme</td><td class=\"tsiData\">00:00:00</td></tr><tr><td class=\"tsiLabel\">D&eacute;c&eacute;l&eacute;rations hors-norme / dur&eacute;e de roulage"
                    + "</td><td class=\"tsiData\">0.0%</td></tr></table></td><td><img id=\"secTabImgDecAlarm"
                    + irang + "\" class=\"secTabLegendImg\"></td></tr></table><br /><br />";
            secuInfos = secuInfos + "<img id=\"imgChart" + irang
                    + "\" class=\"siCatIcon\"/><label class=\"siLabel\">Vitesse</label><hr /><br />"
                    + "<div class=\"alignToChart\">S&eacute;lectionnez une zone du graphe avec la souris pour zoomer. Double-cliquez pour revenir au niveau de zoom initial."
                    + "<br/>Passez la souris sur la graphe pour afficher le d&eacute;tail d'un point.</div><br/><div><div id=\"speedChart"
                    + irang + "\" class=\"speedChart\"></div></div><br/><br/></div>";
        }
        return secuInfos;
    }

    public static double tempsDep(double tms1, double tmsap, double tmsav, int vit1, int vitap, int vitav,
            int vitmax) {
        double tmps = 0;

        double dtms = tmsap - tms1;
        double dvit = Math.abs(vit1 - vitap);
        double dtmsA = tms1 - tmsav;
        double dvitA = Math.abs(vit1 - vitav);

        double kms = dvit / dtms;
        double kmsA = dvitA / dtmsA;
        tmps = (vit1 - vitmax) / kms + (vit1 - vitmax) / kmsA;

        //System.out.println("dtms:" +dtms + " dvit:"+ dvit+" dtmsA:" +dtmsA + " dvitA:"+ dvitA);

        return tmps;
    };

    private static int getDuration(LinkedList pList, String dvId, int index) {
        int tmps = 0;

        Events evt = (Events) pList.get(index);
        tmps = 0;
        if (index == 0) {
            for (int j = index + 1; j < pList.size(); j++) {
                Events evtnxt = (Events) pList.get(j);
                if (evtnxt.getSpeed() > 1.0) {
                    double diff = evtnxt.getDateEvt().getTime() - evt.getDateEvt().getTime();
                    tmps = (int) diff / 1000;
                    j = pList.size();
                }
            }
        } else {
            Events evtbef = (Events) pList.get(index - 1);
            if (evtbef.getSpeed() > 0.) {
                for (int j = index + 1; j < pList.size(); j++) {
                    Events evtnxt = (Events) pList.get(j);
                    if (evtnxt.getSpeed() > 1.0) {
                        double diff = evtnxt.getDateEvt().getTime() - evt.getDateEvt().getTime();
                        tmps = (int) diff / 1000;
                        j = pList.size();
                    }
                }
            }
        }

        /*for (int i = index; i < pList.size(); i++) {
           Events evt = (Events) pList.get(i);
           if (evt.getDeviceID().equals(dvId)) {
            int k = i + 1;
            tmps = 0;
             if (k < pList.size()){
                 Events evtnxt = (Events) pList.get(k);
                 if (evtnxt.getDeviceID().equals(dvId)){
                    double diff = evtnxt.getDateEvt().getTime() - evt.getDateEvt().getTime();
                    tmps = (int) diff / 1000;
                    i = pList.size();
                 }                      
             }            
           }
        }*/
        //System.out.println("duree: "+tmps);
        return tmps;
    }

    private static String getDurationString(int seconds) {

        int hours = seconds / 3600;
        int minutes = (seconds % 3600) / 60;
        seconds = seconds % 60;

        return twoDigitString(hours) + ":" + twoDigitString(minutes) + ":" + twoDigitString(seconds);
    }

    private static String twoDigitString(int number) {

        if (number == 0) {
            return "00";
        }

        if (number / 10 == 0) {
            return "0" + number;
        }

        return String.valueOf(number);
    }

    public static boolean calculProx(double latitude, double longitude, double latitudelast, double longitudelast) {
        boolean proxim = false;

        if (Math.abs(latitudelast - latitude) < 0.00009 && Math.abs(longitudelast - longitude) < 0.00009)
            proxim = true;
        else
            proxim = false;

        return proxim;
    }

    public static LinkedList createTemporaryTable(Connection c, Statement s, String account) {
        ResultSet rs = null;
        boolean flag, proximite;
        boolean first = true;
        boolean topwrite = true;
        boolean statuslast = true;
        String devIDlast = "";
        String acIDlast = "";
        Timestamp dateEVlast = null;
        double latitudelast = 0;
        double longitudelast = 0;
        double odometerKMlast = 0;
        double odometerOffsetKMlast = 0;
        int headinglast = 0;
        double vitesselast = 0;
        int statusCodelast = -1;
        int nbevt = 0;
        int duree = 0;
        int i = 0;
        int nbrDevice = 0;

        formatSymbols.setDecimalSeparator('.');
        DecimalFormat dec = new DecimalFormat("#00.000000", formatSymbols);
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, -1);
        Date dateBefore1Days = cal.getTime();
        //System.out.println(new SimpleDateFormat("yyyy-MM-dd").format(dateBefore1Days));
        date_trt = new SimpleDateFormat("yyyy-MM-dd").format(dateBefore1Days);
        String date_fin = date_trt + " 23:59:59";
        date_trt = date_trt + " 00:00:00";
        LinkedList<Events> eventsList = new LinkedList<Events>();

        StringBuffer sb = new StringBuffer();
        //String sentence = "CREATE TEMPORARY TABLE datatmpEvt( tmpid int NOT NULL AUTO_INCREMENT, accountID varchar(45), deviceID varchar(45), dateEvt Timestamp, lat double, lon double, speed int, tmps int, first boolean, odometerKM double, odometerOffsetKM double, statusCode int, deviceSpeedLimit int,PRIMARY KEY(tmpid), INDEX(tmpid));";
        try {
            Statement st = c.createStatement();
            //s.executeUpdate(sentence);
            String sql = "SELECT count(*) as nbrDevice from Device WHERE accountID='" + account + "';";
            ResultSet rs1 = st.executeQuery(sql);
            if (rs1.next()) {
                nbrDevice = rs1.getObject("nbrDevice") != null ? rs1.getInt("nbrDevice") : null;
                deviceID = new String[nbrDevice];
                deviceSpeedLimit = new String[nbrDevice];
                sql = "SELECT accountID, deviceID, speedLimitKPH from Device WHERE accountID='" + account + "';";
                ResultSet rs2 = st.executeQuery(sql);
                for (flag = rs2.next(); flag; flag = rs2.next()) {
                    deviceID[i] = rs2.getString("deviceID");
                    deviceSpeedLimit[i] = rs2.getString("speedLimitKPH");
                    //System.out.println(rs2.getString("accountID") + " " + deviceID[i]+" Vitesse limite:"+deviceSpeedLimit[i]+"kms/h");
                    i++;
                }
                //String sql = "SELECT accountID, FROM_UNIXTIME(timestamp) as timestamp, deviceID, latitude, longitude, speedKPH FROM EventData WHERE accountID='telo' and deviceID='telo1' and DATE_FORMAT(FROM_UNIXTIME(timestamp),'%y-%m-%d') = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 day),'%y-%m-%d') order by deviceID,timestamp;";
                //DATE_FORMAT(NOW(),'%y-%m-%d')
                sql = "SELECT accountID, FROM_UNIXTIME(timestamp) as timestamp, deviceID, latitude, longitude, speedKPH, odometerKM, odometerOffsetKM, statusCode, heading FROM EventData WHERE accountID='"
                        + account + "' and longitude <> 0.0 and FROM_UNIXTIME(timestamp) >= '" + date_trt
                        + "' and FROM_UNIXTIME(timestamp) <= '" + date_fin + "' order by deviceID,timestamp;";
                System.out.println(sql);
                rs = st.executeQuery(sql);
                // lecture premier enregistrement
                if (rs.next()) {
                    acIDlast = rs.getObject("accountID") != null ? rs.getString("accountID") : null;
                    devIDlast = rs.getObject("accountID") != null ? rs.getString("deviceID") : null;
                    dateEVlast = rs.getTimestamp("timestamp");
                    latitudelast = rs.getObject("latitude") != null ? rs.getDouble("latitude") : null;
                    longitudelast = rs.getObject("longitude") != null ? rs.getDouble("longitude") : null;
                    vitesselast = rs.getObject("speedKPH") != null ? rs.getInt("speedKPH") : null;
                    statusCodelast = rs.getObject("statusCode") != null ? rs.getInt("statusCode") : null;
                    //vitesselast = 0.;
                    odometerKMlast = rs.getObject("odometerKM") != null ? rs.getDouble("odometerKM") : null;
                    odometerOffsetKMlast = rs.getObject("odometerOffsetKM") != null
                            ? rs.getDouble("odometerOffsetKM")
                            : null;
                    int statusCode = rs.getObject("statusCode") != null ? rs.getInt("statusCode") : null;
                    headinglast = rs.getObject("heading") != null ? rs.getInt("heading") : 0;
                    statuslast = true;
                    int speedLimit = 0;
                    for (int id = 0; id < nbrDevice; id++) {
                        if (devIDlast.equalsIgnoreCase(deviceID[id])) {
                            speedLimit = Integer.parseInt(deviceSpeedLimit[id]);
                            id = nbrDevice;
                        } else
                            speedLimit = 0;

                    }
                    eventsList.add(new Events(acIDlast, devIDlast, latitudelast, longitudelast, vitesselast,
                            dateEVlast, odometerKMlast, odometerOffsetKMlast, statusCode, speedLimit, headinglast));
                    nbevt++;
                    //Events evt = (Events) eventsList.get(0);
                    //System.out.println(evt.getAccountID() + " " + evt.getDeviceID() + " " + new SimpleDateFormat("yyy-MM-dd HH:mm:ss").format(evt.getDateEvt()) + " " + dec.format(evt.getLatitude()) + " "+ dec.format(evt.getLongitude()) + " " + evt.getSpeed() + " " + evt.getOdometerKM() + " " + evt.getSpeedMax() + " "+evt.getStatusCode());

                    for (flag = rs.next(); flag; flag = rs.next()) {
                        String acID = rs.getObject("accountID") != null ? rs.getString("accountID") : null;
                        String devID = rs.getObject("accountID") != null ? rs.getString("deviceID") : null;
                        Timestamp dateEV = rs.getTimestamp("timestamp");
                        double latitude = rs.getObject("latitude") != null ? rs.getDouble("latitude") : null;
                        double longitude = rs.getObject("longitude") != null ? rs.getDouble("longitude") : null;
                        double vitesse = rs.getObject("speedKPH") != null ? rs.getInt("speedKPH") : null;
                        double odometerKM = rs.getObject("odometerKM") != null ? rs.getDouble("odometerKM") : null;
                        double odometerOffsetKM = rs.getObject("odometerOffsetKM") != null
                                ? rs.getDouble("odometerOffsetKM")
                                : null;
                        statusCode = rs.getObject("statusCode") != null ? rs.getInt("statusCode") : null;
                        int heading = rs.getObject("heading") != null ? rs.getInt("heading") : 0;
                        //System.out.println(acID + " " + devID + " " + new SimpleDateFormat("yyy-MM-dd HH:mm:ss").format(dateEV) + " " + latitude + " "+ longitude + " " + vitesse);
                        //proximite = calculProx(latitude, longitude, latitudelast, longitudelast);
                        for (int id = 0; id < nbrDevice; id++) {
                            if (devIDlast.equalsIgnoreCase(deviceID[id])) {
                                speedLimit = Integer.parseInt(deviceSpeedLimit[id]);
                                id = nbrDevice;
                            } else
                                speedLimit = 0;

                        }
                        if (devIDlast.equalsIgnoreCase(devID)) {
                            /*if (vitesse == 0.0 && vitesselast == 0.0 && (odometerKM - odometerKMlast) < 1){
                            } 
                            else*/ {
                                if (INTERPOLATION) {
                                    long diff = dateEV.getTime() - dateEVlast.getTime();
                                    duree = (int) diff / 1000;
                                    if (duree > 120) {
                                        eventsList = addpointsList(acID, devID, eventsList, latitude, longitude,
                                                dateEV, vitesse, odometerKM, odometerOffsetKM, statusCode,
                                                speedLimit, heading);
                                        nbevt++;
                                    } else {
                                        eventsList.add(new Events(acID, devID, latitude, longitude, vitesse, dateEV,
                                                odometerKM, odometerOffsetKM, statusCode, speedLimit, heading));
                                        nbevt++;
                                        //evt = (Events) eventsList.get(eventsList.size()-1);
                                        //System.out.println(evt.getAccountID() + " " + evt.getDeviceID() + " " + new SimpleDateFormat("yyy-MM-dd HH:mm:ss").format(evt.getDateEvt()) + " " + dec.format(evt.getLatitude()) + " "+ dec.format(evt.getLongitude()) + " " + evt.getSpeed() + " " + evt.getOdometerKM() + " " + evt.getSpeedMax() + " "+evt.getStatusCode());
                                    }
                                } else {
                                    eventsList.add(new Events(acID, devID, latitude, longitude, vitesse, dateEV,
                                            odometerKM, odometerOffsetKM, statusCode, speedLimit, heading));
                                    nbevt++;
                                }
                                if (vitesse == 0.0 && vitesselast == 0.0) {

                                } else {
                                    devIDlast = devID;
                                    acIDlast = acID;
                                    dateEVlast = dateEV;
                                    latitudelast = latitude;
                                    longitudelast = longitude;
                                    vitesselast = vitesse;
                                    odometerKMlast = odometerKM;
                                    odometerOffsetKMlast = odometerOffsetKM;
                                    statusCodelast = statusCode;
                                    headinglast = heading;
                                }
                            }
                        } else {
                            eventsList.add(new Events(acID, devID, latitude, longitude, vitesse, dateEV, odometerKM,
                                    odometerOffsetKM, statusCode, speedLimit, heading));
                            devIDlast = devID;
                            acIDlast = acID;
                            dateEVlast = dateEV;
                            latitudelast = latitude;
                            longitudelast = longitude;
                            vitesselast = vitesse;
                            odometerKMlast = odometerKM;
                            odometerOffsetKMlast = odometerOffsetKM;
                            statusCodelast = statusCode;
                            headinglast = heading;
                            //evt = (Events) eventsList.get(eventsList.size()-1);
                            //System.out.println(evt.getAccountID() + " " + evt.getDeviceID() + " " + new SimpleDateFormat("yyy-MM-dd HH:mm:ss").format(evt.getDateEvt()) + " " + dec.format(evt.getLatitude()) + " "+ dec.format(evt.getLongitude()) + " " + evt.getSpeed() + " " + evt.getOdometerKM() + " " + evt.getSpeedMax() + " "+evt.getStatusCode());
                        }

                        /*if (devIDlast.equalsIgnoreCase(devID) && vitesse < 1 && vitesselast < 1) {
                           topwrite = false;
                        }
                        else {   
                           long diff = dateEV.getTime() - dateEVlast.getTime() ;
                           duree = (int) diff / 1000;
                           if (devIDlast.equalsIgnoreCase(devID)) {
                        if (statuslast) { 
                           first = true;
                           duree = 0;
                        }
                        statuslast = false;
                           }
                           else {
                        statuslast = true;
                        duree = 0;
                           }
                        if (first) { 
                           duree = 0;
                           //vitesselast = 0;
                        }
                        for(int id=0 ;id < nbrDevice;id++){
                           if (devIDlast.equalsIgnoreCase(deviceID[id])){
                              speedLimit = Integer.parseInt(deviceSpeedLimit[id]);
                              id = nbrDevice;
                           } else speedLimit = 0;
                                  
                        }
                             sentence = "INSERT INTO datatmpEvt(accountID, deviceID, dateEvt, lat, lon, speed, tmps, first, odometerKM, odometerOffsetKM, statusCode, deviceSpeedLimit) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
                             PreparedStatement pstmt = c.prepareStatement(sentence);
                         pstmt.setString(1, acIDlast);
                         pstmt.setString(2, devIDlast);
                         pstmt.setTimestamp(3, dateEVlast);
                         pstmt.setDouble(4, latitudelast);
                         pstmt.setDouble(5, longitudelast);
                         pstmt.setDouble(6, vitesselast);
                         pstmt.setInt(7, duree);
                         pstmt.setBoolean(8, first);
                         pstmt.setDouble(9, odometerKMlast);
                         pstmt.setDouble(10, odometerOffsetKMlast);
                         pstmt.setInt(11, statusCodelast);
                         pstmt.setInt(12, speedLimit);
                        pstmt.executeUpdate();
                             nbevt++;
                            
                             devIDlast = devID;
                             acIDlast = acID;
                        dateEVlast = dateEV;
                        latitudelast = latitude;
                        longitudelast = longitude;
                        vitesselast = vitesse;
                        odometerKMlast = odometerKM;
                        odometerOffsetKMlast = odometerOffsetKM;
                        statusCodelast = statusCode;
                        first = false;
                        }*/
                    }
                    /*if (topwrite){
                       for(int id=0 ;id < nbrDevice;id++){
                     if (devIDlast.equalsIgnoreCase(deviceID[id])){
                        speedLimit = Integer.parseInt(deviceSpeedLimit[id]);
                        id = nbrDevice;
                     } else speedLimit = 0;
                            
                       }
                    sentence = "INSERT INTO datatmpEvt(accountID, deviceID, dateEvt, lat, lon, speed, tmps, first, odometerKM, odometerOffsetKM, statusCode, deviceSpeedLimit) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
                    PreparedStatement pstmt = c.prepareStatement(sentence);
                     pstmt.setString(1, acIDlast);
                     pstmt.setString(2, devIDlast);
                     pstmt.setTimestamp(3, dateEVlast);
                     pstmt.setDouble(4, latitudelast);
                     pstmt.setDouble(5, longitudelast);
                     pstmt.setDouble(6, 0.0D);
                     pstmt.setInt(7, 0);
                     pstmt.setBoolean(8, first);
                     pstmt.setDouble(9, odometerKMlast);
                     pstmt.setDouble(10, odometerOffsetKMlast);
                      pstmt.setInt(11, statusCodelast);
                      pstmt.setInt(12, speedLimit);
                     pstmt.executeUpdate();
                    nbevt++;
                    }*/
                }
                rs2.close();
            }
            rs1.close();
            rs.close();

            for (int j = 0; j < eventsList.size(); j++) {
                Events evt = (Events) eventsList.get(j);
                System.out.println(evt.getAccountID() + " " + evt.getDeviceID() + " "
                        + new SimpleDateFormat("yyy-MM-dd HH:mm:ss").format(evt.getDateEvt()) + " "
                        + dec.format(evt.getLatitude()) + " " + dec.format(evt.getLongitude()) + " "
                        + evt.getSpeed() + " " + evt.getOdometerKM() + " " + evt.getSpeedMax() + " "
                        + evt.getStatusCode() + " " + evt.getHeading());

            }

        } catch (SQLException e) {
            e.printStackTrace();
        }

        System.out.println("Chargement de la table termin. Nb=" + nbevt);
        return eventsList;
    }

    public static LinkedList addpoints(String acId, String dvId, LinkedList pList) {
        String secuInfos = "";
        int nbrarret = 0;
        int nbrpoints = 0;
        double distance;
        int startIndex = 0;
        int startIndexEnd = 0;

        LinkedList<Events> pListnw = new LinkedList<Events>();
        Events evtnxt = null;
        for (int i = 0; i < pList.size(); i++) {
            Events evt = (Events) pList.get(i);
            if (evt.getDeviceID().equalsIgnoreCase(dvId)) {
                String request = "";
                int k = i + 2;
                if (k >= pList.size())
                    k = pList.size();
                for (int j = i; j < k; j++) {
                    evtnxt = (Events) pList.get(j);
                    if (evtnxt.getDeviceID().equals(dvId)) {
                        request = request + "loc=" + evtnxt.getLatitude() + "," + evtnxt.getLongitude();
                        nbrpoints++;
                        startIndexEnd = j;
                    }
                }
                if (nbrpoints > 1) {
                    request = osrm + request + "&instructions=false&alt=false";
                    ArrayList<Location> polyline = sendGetLoc(request, "viaroute");
                    //distance = Double.parseDouble(rep[0])/1000.0;

                    if (polyline != null) {
                        double tempsnv = (evtnxt.getDateEvt().getTime() - evt.getDateEvt().getTime())
                                / polyline.size();
                        double temps = ((evtnxt.getDateEvt().getTime() - evt.getDateEvt().getTime()) / 1000.0)
                                / 3600;
                        //System.out.println("Nombre de point nv:" + polyline.size()+ " tmps a ajouter = "+ tempsnv);
                        for (int ip = 0; ip < polyline.size(); ip++) {
                            double tmps = evt.getDateEvt().getTime() + (tempsnv * (ip + 1));
                            int dist = Integer.parseInt(((Location) polyline.get(ip)).getDistance()) / 1000;
                            double vitessenv = dist / temps;
                            double lat = ((Location) polyline.get(ip)).getLatitude();
                            double lon = ((Location) polyline.get(ip)).getLongitude();
                            Timestamp tm = new Timestamp(
                                    (long) (evt.getDateEvt().getTime() + (tempsnv * (ip + 1))));
                            //System.out.println("ip:" + ip+ "tmps = "+ tmps + " vitessenv: "+vitessenv);
                            //System.out.println("donne  l'indice " + ip + " = " +lat+ "," +lon+", "+tm.getTime()+" vit: "+vitessenv);
                            pListnw.add(new Events(acId, dvId, lat, lon, vitessenv, tm, 0.0, 0.0, -1,
                                    (int) evt.getSpeedMax(), 0));
                            if (startIndex < 1)
                                startIndex = i;
                        }
                    }
                }
                request = "";
                nbrpoints = 0;
                i = k - 1;
            }
        }
        //pList.addAll(startIndex, pListnw);
        return pListnw;
    }

    public static LinkedList addpointsList(String acId, String dvId, LinkedList pList, double lat, double lon,
            Timestamp dateEV, double vitesse, double odometerKM, double odometerOffsetKM, int statusCode,
            int speedLimit, int heading) {
        double distance;

        LinkedList<Events> pListnw = new LinkedList<Events>();
        Events evtnxt = null;
        int i = pList.size() - 1;
        Events evt = (Events) pList.get(i);
        if (evt.getDeviceID().equalsIgnoreCase(dvId)) {
            String request = "";
            request = "loc=" + evt.getLatitude() + "," + evt.getLongitude() + "loc=" + lat + "," + lon;
            request = osrm + request + "&instructions=false&alt=false";
            //System.out.println(":" +request);
            ArrayList<Location> polyline = sendGetLoc(request, "viaroute");
            if (polyline != null) {
                double tempsnv = (dateEV.getTime() - evt.getDateEvt().getTime()) / polyline.size();
                //System.out.println("dateEV:"+new SimpleDateFormat("yyy-MM-dd HH:mm:ss").format(dateEV)+" evt.getDateEvt():"+new SimpleDateFormat("yyy-MM-dd HH:mm:ss").format(evt.getDateEvt()));
                double temps = ((dateEV.getTime() - evt.getDateEvt().getTime()) / 1000.0) / 3600;
                //System.out.println("Nombre de point nv:" + polyline.size()+ " tmps a ajouter = "+ tempsnv+ " dif:"+temps);
                for (int ip = 0; ip < polyline.size(); ip++) {
                    double tmps = evt.getDateEvt().getTime() + (tempsnv * (ip + 1));
                    int dist = Integer.parseInt(((Location) polyline.get(ip)).getDistance()) / 1000;
                    double vitessenv = dist / temps;
                    double la = ((Location) polyline.get(ip)).getLatitude();
                    double lo = ((Location) polyline.get(ip)).getLongitude();
                    Timestamp tm = new Timestamp((long) (evt.getDateEvt().getTime() + (tempsnv * (ip + 1))));
                    //System.out.println("ip:" + ip+ "tmps = "+ tmps + " vitessenv: "+vitessenv);
                    //System.out.println("donne  l'indice " + ip + " = " +lat+ "," +lon+", "+tm.getTime()+" vit: "+vitessenv);
                    pList.add(new Events(acId, dvId, la, lo, (int) vitessenv, tm,
                            evt.getOdometerKM() + (dist * (ip + 1)), 0.0, -1, speedLimit, heading));
                    Events evtds = (Events) pList.get(pList.size() - 1);
                    //System.out.println(evtds.getAccountID() + " " + evtds.getDeviceID() + " " + new SimpleDateFormat("yyy-MM-dd HH:mm:ss").format(evtds.getDateEvt()) + " " +evtds.getLatitude() + " "+ evtds.getLongitude() + " " + evtds.getSpeed() + " " + evtds.getOdometerKM() + " " + evtds.getSpeedMax() + " "+evtds.getStatusCode());
                }
                //pList.addAll(pList.size() - 1, pListnw);
            } else {
                pList.add(new Events(acId, dvId, lat, lon, (int) vitesse, dateEV, odometerKM, odometerOffsetKM,
                        statusCode, speedLimit, heading));
                //System.out.println(acId + " " + dvId + " " + new SimpleDateFormat("yyy-MM-dd HH:mm:ss").format(dateEV) + " " + lat  + " "+ lon + " " + vitesse + " " + odometerKM + " " + odometerOffsetKM + " "+speedLimit);
            }
            pListnw = pList;
        }
        //pList.addAll(startIndex, pListnw);
        return pListnw;
    }

    // HTTP GET request
    @SuppressWarnings("deprecation")
    private static String sendGet(String url, String type) {
        String genreJson;
        String distance = "0";

        //rep = new String[2];
        JSONParser parser = new JSONParser();
        ArrayList polyline = new ArrayList();
        try {
            JSONArray genreArray = null;
            if (type.equalsIgnoreCase("match")) {
                //url = osrm+"loc="+lat1+","+lon1+"&t="+tms1+"loc="+lat2+","+lon2+"&t="+tms2+"&compression=true";
                genreJson = IOUtils.toString(new URL(url));
                JSONObject genreJsonObject = (JSONObject) JSONValue.parseWithException(genreJson);

                genreArray = (JSONArray) genreJsonObject.get("matchings");
                //System.out.println(genreArray);
                if (genreArray == null) {
                    System.out.println("JMapData not found in JSON response");
                    distance = "0";
                } else {
                    // get the first genre
                    JSONObject firstGenre = (JSONObject) genreArray.get(0);
                    JSONObject routesummary = (JSONObject) firstGenre.get("route_summary");
                    distance = routesummary.get("total_distance").toString();
                }
                //rep[0] = distance;
            } else {
                //url = osrm+"loc="+lat1+","+lon1+"&loc="+lat2+","+lon2+"&instructions=false&alt=false";
                genreJson = IOUtils.toString(new URL(url));
                JSONObject genreJsonObject = (JSONObject) JSONValue.parseWithException(genreJson);

                JSONObject firstGenre = (JSONObject) genreJsonObject.get("route_summary");
                //System.out.println(firstGenre.get("total_distance").toString());
                distance = firstGenre.get("total_distance").toString();
            }

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return distance;
    }

    // HTTP GET request
    @SuppressWarnings("deprecation")
    private static ArrayList<Location> sendGetLoc(String url, String type) {
        String genreJson;
        String distance = "0";
        ArrayList rep;

        //rep = new String[2];
        JSONParser parser = new JSONParser();
        ArrayList polyline = new ArrayList();
        try {
            JSONArray genreArray = null;
            if (type.equalsIgnoreCase("match")) {
                //url = "http://192.168.0.12:5000/match?loc="+lat1+","+lon1+"&t="+tms1+"loc="+lat2+","+lon2+"&t="+tms2+"&compression=true";
                genreJson = IOUtils.toString(new URL(url));
                JSONObject genreJsonObject = (JSONObject) JSONValue.parseWithException(genreJson);

                genreArray = (JSONArray) genreJsonObject.get("matchings");
                //System.out.println(genreArray);
                if (genreArray == null) {
                    System.out.println("JMapData not found in JSON response");
                    distance = "0";
                } else {
                    // get the first genre
                    JSONObject firstGenre = (JSONObject) genreArray.get(0);
                    JSONObject routesummary = (JSONObject) firstGenre.get("route_summary");
                    distance = routesummary.get("total_distance").toString();
                }
                //rep[0] = distance;
            } else {
                //url = "http://192.168.0.1:5000/viaroute?loc="+lat1+","+lon1+"&loc="+lat2+","+lon2+"&instructions=false&alt=false";
                genreJson = IOUtils.toString(new URL(url));
                JSONObject genreJsonObject = (JSONObject) JSONValue.parseWithException(genreJson);

                JSONObject firstGenre = (JSONObject) genreJsonObject.get("route_summary");
                //System.out.println(firstGenre.get("total_distance").toString());
                distance = firstGenre.get("total_distance").toString();
                Object obj = parser.parse(genreJson);

                JSONObject jsonObject = (JSONObject) obj;
                String route_geometry = (String) jsonObject.get("route_geometry");
                polyline = decodePoly(route_geometry, distance);
                // Get size and display.
                //int count = polyline.size();
                //System.out.println("Count: " + count);
                //rep[0] = distance;
                //rep[1] = polyline.toString();
            }

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if ((Integer.parseInt(distance) / 1000) < DISTANCE_MINI_ENTRE_POINT)
            return null;
        else
            return polyline;
    }

    public static ArrayList decodePoly(String encoded, String distance) {
        ArrayList poly = new ArrayList();
        int index = 0, len = encoded.length();
        int lat = 0, lng = 0;
        while (index < len) {
            int b, shift = 0, result = 0;
            do {
                b = encoded.charAt(index++) - 63;
                result |= (b & 0x1f) << shift;
                shift += 5;
            } while (b >= 0x20);
            int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
            lat += dlat;
            shift = 0;
            result = 0;
            do {
                b = encoded.charAt(index++) - 63;
                result |= (b & 0x1f) << shift;
                shift += 5;
            } while (b >= 0x20);
            int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
            lng += dlng;
            Location p = new Location((((double) lat / 1E6)), (((double) lng / 1E6)), distance);
            poly.add(p);
        }
        return poly;
    }

    // ------------------------------------------------------------------------

    private static void readConfig(String file) {
        Properties prop = new Properties();
        InputStream input = null;

        try {

            input = new FileInputStream(file);

            // load a properties file
            prop.load(input);

            // get the property value and print it out
            url = prop.getProperty("url");
            user = prop.getProperty("dbuser");
            password = prop.getProperty("dbpassword");
            osrm = prop.getProperty("osrm");
            MAIL_FROM = prop.getProperty("mailfrom");
            TEMPLATE_NAME = prop.getProperty("template");
            String email = prop.getProperty("sendmail");
            if (email.equalsIgnoreCase("true"))
                SEND_EMAIL = true;
            else
                SEND_EMAIL = false;
            String interpol = prop.getProperty("interpolation");
            if (interpol.equalsIgnoreCase("true"))
                INTERPOLATION = true;
            else
                INTERPOLATION = false;

            System.out.println(url);
            System.out.println(user);
            //System.out.println(password);
            System.out.println(osrm);
            System.out.println(MAIL_FROM);
            System.out.println(TEMPLATE_NAME);
            System.out.println(SEND_EMAIL);
            System.out.println(INTERPOLATION);

        } catch (IOException ex) {
            ex.printStackTrace();
        } finally {
            if (input != null) {
                try {
                    input.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}