|
@@ -24,10 +24,10 @@ public class TrackRestUtil {
|
|
|
*/
|
|
*/
|
|
|
public static String getDatesByUnits(String unitIds) throws SQLException {
|
|
public static String getDatesByUnits(String unitIds) throws SQLException {
|
|
|
String query = "SELECT t.unit_id, t.description, json_agg(t.date_trunc) FROM"
|
|
String query = "SELECT t.unit_id, t.description, json_agg(t.date_trunc) FROM"
|
|
|
- + " (SELECT u.unit_id, u.description, date_trunc('day', up.time_stamp)::date"
|
|
|
|
|
|
|
+ + " (SELECT up.unit_id, u.description, date_trunc('day', up.time_stamp)::date"
|
|
|
+ " FROM public.units_positions up, units u"
|
|
+ " FROM public.units_positions up, units u"
|
|
|
- + " WHERE u.unit_id IN ("+unitIds+") AND u.unit_id = up.unit_id"
|
|
|
|
|
- + " GROUP BY u.unit_id, date_trunc ORDER BY u.unit_id, date_trunc) t"
|
|
|
|
|
|
|
+ + " WHERE up.unit_id IN ("+unitIds+") AND u.unit_id = up.unit_id"
|
|
|
|
|
+ + " GROUP BY up.unit_id, u.description, date_trunc ORDER BY up.unit_id, date_trunc) t"
|
|
|
+ " GROUP BY t.unit_id, t.description;";
|
|
+ " GROUP BY t.unit_id, t.description;";
|
|
|
ResultSet res = SQLExecutor.getInstance().executeQuery(query);
|
|
ResultSet res = SQLExecutor.getInstance().executeQuery(query);
|
|
|
JSONArray units = new JSONArray();
|
|
JSONArray units = new JSONArray();
|
|
@@ -51,11 +51,11 @@ public class TrackRestUtil {
|
|
|
*/
|
|
*/
|
|
|
public static String getDatesByUnitsByGroup(int groupId) throws SQLException {
|
|
public static String getDatesByUnitsByGroup(int groupId) throws SQLException {
|
|
|
String query = "SELECT t.unit_id, t.description, json_agg(t.date_trunc) FROM"
|
|
String query = "SELECT t.unit_id, t.description, json_agg(t.date_trunc) FROM"
|
|
|
- + " (SELECT u.unit_id, u.description, date_trunc('day', up.time_stamp)::date"
|
|
|
|
|
|
|
+ + " (SELECT up.unit_id, u.description, date_trunc('day', up.time_stamp)::date"
|
|
|
+ " FROM public.units_positions up, units u"
|
|
+ " FROM public.units_positions up, units u"
|
|
|
- + " WHERE u.unit_id IN ("
|
|
|
|
|
- + "SELECT unit_id FROM units_to_groups WHERE group_id = "+groupId+")"
|
|
|
|
|
- + " GROUP BY u.unit_id, date_trunc ORDER BY u.unit_id, date_trunc) t"
|
|
|
|
|
|
|
+ + " WHERE up.unit_id IN (SELECT unit_id FROM units_to_groups WHERE group_id = "+groupId+")"
|
|
|
|
|
+ + " AND up.unit_id = u.unit_id"
|
|
|
|
|
+ + " GROUP BY up.unit_id, u.description, date_trunc ORDER BY up.unit_id, date_trunc) t"
|
|
|
+ " GROUP BY t.unit_id, t.description;";
|
|
+ " GROUP BY t.unit_id, t.description;";
|
|
|
ResultSet res = SQLExecutor.getInstance().executeQuery(query);
|
|
ResultSet res = SQLExecutor.getInstance().executeQuery(query);
|
|
|
JSONArray units = new JSONArray();
|
|
JSONArray units = new JSONArray();
|
|
@@ -79,11 +79,11 @@ public class TrackRestUtil {
|
|
|
*/
|
|
*/
|
|
|
public static String getDatesByUnitsByGroup(String groupName) throws SQLException {
|
|
public static String getDatesByUnitsByGroup(String groupName) throws SQLException {
|
|
|
String query = "SELECT t.unit_id, t.description, json_agg(t.date_trunc) FROM"
|
|
String query = "SELECT t.unit_id, t.description, json_agg(t.date_trunc) FROM"
|
|
|
- + " (SELECT u.unit_id, u.description, date_trunc('day', up.time_stamp)::date"
|
|
|
|
|
- + " FROM public.units_positions up, units u"
|
|
|
|
|
- + " WHERE u.unit_id IN ("
|
|
|
|
|
- + "SELECT unit_id FROM units_to_groups utg, groups g WHERE utg.group_id = g.id AND g.group_name='"+groupName+"')"
|
|
|
|
|
- + " GROUP BY u.unit_id, date_trunc ORDER BY u.unit_id, date_trunc) t"
|
|
|
|
|
|
|
+ + " (SELECT up.unit_id, u.description, date_trunc('day', up.time_stamp)::date"
|
|
|
|
|
+ + " FROM public.units_positions up, units u"
|
|
|
|
|
+ + " WHERE up.unit_id IN (SELECT unit_id FROM units_to_groups utg, groups g WHERE utg.group_id = g.id AND g.group_name='"+groupName+"')"
|
|
|
|
|
+ + " AND up.unit_id = u.unit_id"
|
|
|
|
|
+ + " GROUP BY up.unit_id, u.description, date_trunc ORDER BY up.unit_id, date_trunc) t"
|
|
|
+ " GROUP BY t.unit_id, t.description;";
|
|
+ " GROUP BY t.unit_id, t.description;";
|
|
|
ResultSet res = SQLExecutor.getInstance().executeQuery(query);
|
|
ResultSet res = SQLExecutor.getInstance().executeQuery(query);
|
|
|
JSONArray units = new JSONArray();
|
|
JSONArray units = new JSONArray();
|