From 49b99e14c958e29af4acf0f2c3f4900d90a62de9 Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Fri, 22 Mar 2024 12:03:07 +0100 Subject: [PATCH] Adapt the condition --- .../src/main/java/ovh/herisson/Clyde/RegNoGenerator.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/RegNoGenerator.java b/backend/src/main/java/ovh/herisson/Clyde/RegNoGenerator.java index e974a50..c19bc1b 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/RegNoGenerator.java +++ b/backend/src/main/java/ovh/herisson/Clyde/RegNoGenerator.java @@ -20,14 +20,15 @@ public class RegNoGenerator implements IdentifierGenerator { Statement statement = conn.createStatement(); int n = usv.getCount(); - String query = "select count(reg_no)+"+n+" from Users"; - usv.increment(); + Calendar c = new GregorianCalendar(); + int y = c.get(Calendar.YEAR); + String query = "select count(reg_no) + "+n+" from Users where reg_no/10000 = " + y%1000; ResultSet set = statement.executeQuery(query); long resp = 0; - Calendar c = new GregorianCalendar(); if(set.next()){ - resp = set.getLong(1)+((c.get(Calendar.YEAR)%1000)*10000); + resp = set.getLong(1)+((y%1000)*10000); + usv.increment(); } conn.close();