From 026b28853468a78df88950e97ee387ad8a1ef597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9rik=20BENOIST?= Date: Sat, 27 Jan 2024 11:32:41 +0100 Subject: [PATCH 1/4] feat: add bruno api requests --- bruno/artemis/A01 Ticket DLQ (DEV).bru | 20 ++++++++++++++++++++ bruno/artemis/A01 Ticket DLQ (PROD).bru | 20 ++++++++++++++++++++ bruno/artemis/A02 Ticket DLQ (PROD).bru | 20 ++++++++++++++++++++ bruno/authentication/login.bru | 22 ++++++++++++++++++++++ bruno/bruno.json | 5 +++++ bruno/environments/Production.bru | 4 ++++ bruno/environments/local.bru | 4 ++++ bruno/flux/BL/not sent.bru | 11 +++++++++++ bruno/hello/hello 8080.bru | 11 +++++++++++ bruno/items/items.bru | 15 +++++++++++++++ bruno/items/itemsOptions.bru | 15 +++++++++++++++ bruno/items/itemsPrice.bru | 15 +++++++++++++++ bruno/items/itemsStock.bru | 15 +++++++++++++++ bruno/obi/order/GetAllOrders.bru | 18 ++++++++++++++++++ bruno/obi/order/GetByOrderId.bru | 11 +++++++++++ bruno/obi/order/getOrderMessage.bru | 11 +++++++++++ bruno/obi/proximis/projectFulfillment.bru | 11 +++++++++++ bruno/stores/All.bru | 11 +++++++++++ bruno/stores/Log.bru | 16 ++++++++++++++++ bruno/stores/Sequence.bru | 15 +++++++++++++++ bruno/stores/Signature.bru | 15 +++++++++++++++ bruno/stores/StoreById.bru | 11 +++++++++++ bruno/stores/StoreDetails.bru | 15 +++++++++++++++ bruno/stores/Version.bru | 15 +++++++++++++++ bruno/stores/reload.bru | 11 +++++++++++ bruno/xadmin/Log.bru | 16 ++++++++++++++++ 26 files changed, 353 insertions(+) create mode 100644 bruno/artemis/A01 Ticket DLQ (DEV).bru create mode 100644 bruno/artemis/A01 Ticket DLQ (PROD).bru create mode 100644 bruno/artemis/A02 Ticket DLQ (PROD).bru create mode 100644 bruno/authentication/login.bru create mode 100644 bruno/bruno.json create mode 100644 bruno/environments/Production.bru create mode 100644 bruno/environments/local.bru create mode 100644 bruno/flux/BL/not sent.bru create mode 100644 bruno/hello/hello 8080.bru create mode 100644 bruno/items/items.bru create mode 100644 bruno/items/itemsOptions.bru create mode 100644 bruno/items/itemsPrice.bru create mode 100644 bruno/items/itemsStock.bru create mode 100644 bruno/obi/order/GetAllOrders.bru create mode 100644 bruno/obi/order/GetByOrderId.bru create mode 100644 bruno/obi/order/getOrderMessage.bru create mode 100644 bruno/obi/proximis/projectFulfillment.bru create mode 100644 bruno/stores/All.bru create mode 100644 bruno/stores/Log.bru create mode 100644 bruno/stores/Sequence.bru create mode 100644 bruno/stores/Signature.bru create mode 100644 bruno/stores/StoreById.bru create mode 100644 bruno/stores/StoreDetails.bru create mode 100644 bruno/stores/Version.bru create mode 100644 bruno/stores/reload.bru create mode 100644 bruno/xadmin/Log.bru diff --git a/bruno/artemis/A01 Ticket DLQ (DEV).bru b/bruno/artemis/A01 Ticket DLQ (DEV).bru new file mode 100644 index 0000000..05c2ee6 --- /dev/null +++ b/bruno/artemis/A01 Ticket DLQ (DEV).bru @@ -0,0 +1,20 @@ +meta { + name: A01 Ticket DLQ (DEV) + type: http + seq: 1 +} + +get { + url: http://v-artm-a01-iddc.adic.lan:8260/rec/mom1/console/jolokia/read/org.apache.activemq.artemis:broker=!%22mom-rec-001!%22,component=addresses,address=!%22XSTO_ASPD_VTEJ_retail_sale_3211.DLQ!%22,subcomponent=queues,routing-type=!%22anycast!%22,queue=!%22XSTO_ASPD_VTEJ_retail_sale_3211.DLQ!%22/MessageCount + body: none + auth: basic +} + +headers { + Origin: http://v-artm-a01-iddc.adic.lan:8260 +} + +auth:basic { + username: artemis + password: artemis +} diff --git a/bruno/artemis/A01 Ticket DLQ (PROD).bru b/bruno/artemis/A01 Ticket DLQ (PROD).bru new file mode 100644 index 0000000..82c7096 --- /dev/null +++ b/bruno/artemis/A01 Ticket DLQ (PROD).bru @@ -0,0 +1,20 @@ +meta { + name: A01 Ticket DLQ (PROD) + type: http + seq: 2 +} + +get { + url: http://v-artm-a01-ipdc.tech.ikks.lan:8160/console/jolokia/exec/org.apache.activemq.artemis:broker=!%22mom01-v-artm-a01-ipdc!%22,component=addresses,address=!%22XSTO_ASPD_VTEJ_retail_sale_3211.DLQ!%22,subcomponent=queues,routing-type=!%22anycast!%22,queue=!%22XSTO_ASPD_VTEJ_retail_sale_3211.DLQ!%22/countMessages() + body: none + auth: basic +} + +headers { + Origin: http://v-artm-a01-ipdc.tech.ikks.lan:8160 +} + +auth:basic { + username: readonly + password: readonly +} diff --git a/bruno/artemis/A02 Ticket DLQ (PROD).bru b/bruno/artemis/A02 Ticket DLQ (PROD).bru new file mode 100644 index 0000000..ab5f950 --- /dev/null +++ b/bruno/artemis/A02 Ticket DLQ (PROD).bru @@ -0,0 +1,20 @@ +meta { + name: A02 Ticket DLQ (PROD) + type: http + seq: 3 +} + +get { + url: http://v-artm-a02-ipdc.tech.ikks.lan:8160/console/jolokia/exec/org.apache.activemq.artemis:broker=!%22mom02-v-artm-a02-ipdc!%22,component=addresses,address=!%22XSTO_ASPD_VTEJ_retail_sale_3211.DLQ!%22,subcomponent=queues,routing-type=!%22anycast!%22,queue=!%22XSTO_ASPD_VTEJ_retail_sale_3211.DLQ!%22/countMessages() + body: none + auth: basic +} + +headers { + Origin: http://v-artm-a02-ipdc.tech.ikks.lan:8160 +} + +auth:basic { + username: readonly + password: readonly +} diff --git a/bruno/authentication/login.bru b/bruno/authentication/login.bru new file mode 100644 index 0000000..7963a2b --- /dev/null +++ b/bruno/authentication/login.bru @@ -0,0 +1,22 @@ +meta { + name: login + type: http + seq: 1 +} + +post { + url: {{host}}/hdpos/api/auth/login + body: json + auth: none +} + +headers { + Content-Type: application/json +} + +body:json { + { + "username": "fred", + "password": "admin123" + } +} diff --git a/bruno/bruno.json b/bruno/bruno.json new file mode 100644 index 0000000..6c80d1d --- /dev/null +++ b/bruno/bruno.json @@ -0,0 +1,5 @@ +{ + "version": "1", + "name": "hdpos", + "type": "collection" +} \ No newline at end of file diff --git a/bruno/environments/Production.bru b/bruno/environments/Production.bru new file mode 100644 index 0000000..6b2211d --- /dev/null +++ b/bruno/environments/Production.bru @@ -0,0 +1,4 @@ +vars { + host: http://v-xsto-a01-iidc.adic.lan:8080 + proximisHost: https://ikks.omn.proximis.com +} diff --git a/bruno/environments/local.bru b/bruno/environments/local.bru new file mode 100644 index 0000000..78ecf03 --- /dev/null +++ b/bruno/environments/local.bru @@ -0,0 +1,4 @@ +vars { + host: http://localhost:8080 + proximisHost: https://proximis-ikks-recette.stg.proximis.com +} diff --git a/bruno/flux/BL/not sent.bru b/bruno/flux/BL/not sent.bru new file mode 100644 index 0000000..6878a5c --- /dev/null +++ b/bruno/flux/BL/not sent.bru @@ -0,0 +1,11 @@ +meta { + name: not sent + type: http + seq: 1 +} + +get { + url: {{host}}/hdpos/api/flux/bl/notsent + body: none + auth: none +} diff --git a/bruno/hello/hello 8080.bru b/bruno/hello/hello 8080.bru new file mode 100644 index 0000000..0b4258e --- /dev/null +++ b/bruno/hello/hello 8080.bru @@ -0,0 +1,11 @@ +meta { + name: hello 8080 + type: http + seq: 1 +} + +get { + url: {{host}}/hdpos/api/hello + body: none + auth: none +} diff --git a/bruno/items/items.bru b/bruno/items/items.bru new file mode 100644 index 0000000..c544993 --- /dev/null +++ b/bruno/items/items.bru @@ -0,0 +1,15 @@ +meta { + name: items + type: http + seq: 1 +} + +get { + url: {{host}}/hdpos/api/items/BX44145?dbHost=10.100.0.18 + body: none + auth: none +} + +query { + dbHost: 10.100.0.18 +} diff --git a/bruno/items/itemsOptions.bru b/bruno/items/itemsOptions.bru new file mode 100644 index 0000000..e5a87dd --- /dev/null +++ b/bruno/items/itemsOptions.bru @@ -0,0 +1,15 @@ +meta { + name: itemsOptions + type: http + seq: 3 +} + +get { + url: {{host}}/hdpos/api/items/BX44145/options/?dbHost=10.100.0.18 + body: none + auth: none +} + +query { + dbHost: 10.100.0.18 +} diff --git a/bruno/items/itemsPrice.bru b/bruno/items/itemsPrice.bru new file mode 100644 index 0000000..44b9d4f --- /dev/null +++ b/bruno/items/itemsPrice.bru @@ -0,0 +1,15 @@ +meta { + name: itemsPrice + type: http + seq: 4 +} + +get { + url: {{host}}/hdpos/api/items/BX44145/price/?dbHost=10.100.0.18 + body: none + auth: none +} + +query { + dbHost: 10.100.0.18 +} diff --git a/bruno/items/itemsStock.bru b/bruno/items/itemsStock.bru new file mode 100644 index 0000000..efa364a --- /dev/null +++ b/bruno/items/itemsStock.bru @@ -0,0 +1,15 @@ +meta { + name: itemsStock + type: http + seq: 5 +} + +get { + url: {{host}}/hdpos/api/items/BX44145/stock/?dbHost=10.100.0.18 + body: none + auth: none +} + +query { + dbHost: 10.100.0.18 +} diff --git a/bruno/obi/order/GetAllOrders.bru b/bruno/obi/order/GetAllOrders.bru new file mode 100644 index 0000000..2054e6a --- /dev/null +++ b/bruno/obi/order/GetAllOrders.bru @@ -0,0 +1,18 @@ +meta { + name: GetAllOrders + type: http + seq: 2 +} + +get { + url: {{host}}/hdpos/api/obi/order?page=1&itemsPerPage=10&sortBy=order_id&orderBy=desc + body: none + auth: none +} + +query { + page: 1 + itemsPerPage: 10 + sortBy: order_id + orderBy: desc +} diff --git a/bruno/obi/order/GetByOrderId.bru b/bruno/obi/order/GetByOrderId.bru new file mode 100644 index 0000000..d3a7a60 --- /dev/null +++ b/bruno/obi/order/GetByOrderId.bru @@ -0,0 +1,11 @@ +meta { + name: GetByOrderId + type: http + seq: 1 +} + +get { + url: {{host}}/hdpos/api/obi/order/2845 + body: none + auth: none +} diff --git a/bruno/obi/order/getOrderMessage.bru b/bruno/obi/order/getOrderMessage.bru new file mode 100644 index 0000000..23b613f --- /dev/null +++ b/bruno/obi/order/getOrderMessage.bru @@ -0,0 +1,11 @@ +meta { + name: getOrderMessage + type: http + seq: 3 +} + +get { + url: {{host}}/hdpos/api/obi/order/2845/orderMessage + body: none + auth: none +} diff --git a/bruno/obi/proximis/projectFulfillment.bru b/bruno/obi/proximis/projectFulfillment.bru new file mode 100644 index 0000000..701798e --- /dev/null +++ b/bruno/obi/proximis/projectFulfillment.bru @@ -0,0 +1,11 @@ +meta { + name: projectFulfillment + type: http + seq: 1 +} + +get { + url: {{host}}/hdpos/api/proximis/project/fulfillment/1382020000066 + body: none + auth: none +} diff --git a/bruno/stores/All.bru b/bruno/stores/All.bru new file mode 100644 index 0000000..708cfa1 --- /dev/null +++ b/bruno/stores/All.bru @@ -0,0 +1,11 @@ +meta { + name: All + type: http + seq: 2 +} + +get { + url: {{host}}/hdpos/api/stores/ + body: none + auth: none +} diff --git a/bruno/stores/Log.bru b/bruno/stores/Log.bru new file mode 100644 index 0000000..c856409 --- /dev/null +++ b/bruno/stores/Log.bru @@ -0,0 +1,16 @@ +meta { + name: Log + type: http + seq: 9 +} + +get { + url: {{host}}/hdpos/api/stores/4/log?dbHost=10.100.0.18&logDate=20231228 + body: none + auth: none +} + +query { + dbHost: 10.100.0.18 + logDate: 20231228 +} diff --git a/bruno/stores/Sequence.bru b/bruno/stores/Sequence.bru new file mode 100644 index 0000000..33b6c5a --- /dev/null +++ b/bruno/stores/Sequence.bru @@ -0,0 +1,15 @@ +meta { + name: Sequence + type: http + seq: 1 +} + +get { + url: {{host}}/hdpos/api/stores/4/sequence?dbHost=10.100.0.18 + body: none + auth: none +} + +query { + dbHost: 10.100.0.18 +} diff --git a/bruno/stores/Signature.bru b/bruno/stores/Signature.bru new file mode 100644 index 0000000..53b613c --- /dev/null +++ b/bruno/stores/Signature.bru @@ -0,0 +1,15 @@ +meta { + name: Signature + type: http + seq: 7 +} + +get { + url: {{host}}/hdpos/api/stores/4/signature?dbHost=10.100.0.18 + body: none + auth: none +} + +query { + dbHost: 10.100.0.18 +} diff --git a/bruno/stores/StoreById.bru b/bruno/stores/StoreById.bru new file mode 100644 index 0000000..2c04e88 --- /dev/null +++ b/bruno/stores/StoreById.bru @@ -0,0 +1,11 @@ +meta { + name: StoreById + type: http + seq: 3 +} + +get { + url: {{host}}/hdpos/api/stores/4 + body: none + auth: none +} diff --git a/bruno/stores/StoreDetails.bru b/bruno/stores/StoreDetails.bru new file mode 100644 index 0000000..da319b5 --- /dev/null +++ b/bruno/stores/StoreDetails.bru @@ -0,0 +1,15 @@ +meta { + name: StoreDetails + type: http + seq: 4 +} + +get { + url: {{host}}/hdpos/api/stores/4/details?dbHost=10.100.0.18 + body: none + auth: none +} + +query { + dbHost: 10.100.0.18 +} diff --git a/bruno/stores/Version.bru b/bruno/stores/Version.bru new file mode 100644 index 0000000..56d2225 --- /dev/null +++ b/bruno/stores/Version.bru @@ -0,0 +1,15 @@ +meta { + name: Version + type: http + seq: 6 +} + +get { + url: {{host}}/hdpos/api/stores/4/version?dbHost=10.100.0.18 + body: none + auth: none +} + +query { + dbHost: 10.100.0.18 +} diff --git a/bruno/stores/reload.bru b/bruno/stores/reload.bru new file mode 100644 index 0000000..1f56404 --- /dev/null +++ b/bruno/stores/reload.bru @@ -0,0 +1,11 @@ +meta { + name: reload + type: http + seq: 8 +} + +get { + url: {{host}}/hdpos/api/stores/reload + body: none + auth: none +} diff --git a/bruno/xadmin/Log.bru b/bruno/xadmin/Log.bru new file mode 100644 index 0000000..a899e9d --- /dev/null +++ b/bruno/xadmin/Log.bru @@ -0,0 +1,16 @@ +meta { + name: Log + type: http + seq: 1 +} + +get { + url: {{host}}/hdpos/api/xadmin/log?beginDate=20240101&endDate=20240101 + body: none + auth: none +} + +query { + beginDate: 20240101 + endDate: 20240101 +} -- 2.40.1 From 851a92726510f8c26eb1dca53d6787271a3b2182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9rik=20BENOIST?= Date: Mon, 12 Feb 2024 23:33:21 +0100 Subject: [PATCH 2/4] feat: chatRCT --- bruno/chatrct/PromptDistributor.bru | 15 ++ bruno/chatrct/PromptRCT.bru | 11 ++ bruno/chatrct/hello.bru | 11 ++ .../com/example/services/ChatRctService.java | 132 ++++++++++++++++++ .../com/example/services/OrderService.java | 1 - .../com/example/services/ProximisService.java | 51 +++---- src/main/resources/db.properties | 3 + src/main/resources/env.properties | 2 +- 8 files changed, 200 insertions(+), 26 deletions(-) create mode 100644 bruno/chatrct/PromptDistributor.bru create mode 100644 bruno/chatrct/PromptRCT.bru create mode 100644 bruno/chatrct/hello.bru create mode 100644 src/main/java/com/example/services/ChatRctService.java diff --git a/bruno/chatrct/PromptDistributor.bru b/bruno/chatrct/PromptDistributor.bru new file mode 100644 index 0000000..91c15a4 --- /dev/null +++ b/bruno/chatrct/PromptDistributor.bru @@ -0,0 +1,15 @@ +meta { + name: PromptDistributor + type: http + seq: 3 +} + +get { + url: {{host}}/hdpos/api/chatrct/distributor/1?itemId=XY10000-08-3A + body: none + auth: none +} + +query { + itemId: XY10000-08-3A +} diff --git a/bruno/chatrct/PromptRCT.bru b/bruno/chatrct/PromptRCT.bru new file mode 100644 index 0000000..3fc41e0 --- /dev/null +++ b/bruno/chatrct/PromptRCT.bru @@ -0,0 +1,11 @@ +meta { + name: PromptRCT + type: http + seq: 2 +} + +get { + url: {{host}}/hdpos/api/chatrct/rct/XY10000-08-3A + body: none + auth: none +} diff --git a/bruno/chatrct/hello.bru b/bruno/chatrct/hello.bru new file mode 100644 index 0000000..37beaf2 --- /dev/null +++ b/bruno/chatrct/hello.bru @@ -0,0 +1,11 @@ +meta { + name: Hello + type: http + seq: 1 +} + +get { + url: {{host}}/hdpos/api/chatrct/hello + body: none + auth: none +} \ No newline at end of file diff --git a/src/main/java/com/example/services/ChatRctService.java b/src/main/java/com/example/services/ChatRctService.java new file mode 100644 index 0000000..fffeec7 --- /dev/null +++ b/src/main/java/com/example/services/ChatRctService.java @@ -0,0 +1,132 @@ +package com.example.services; + +import java.sql.CallableStatement; +import java.sql.Clob; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Types; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@Path("/chatrct") +public class ChatRctService { + private static final Logger logger = LoggerFactory.getLogger(ChatRctService.class); + + @GET + @Path("/hello") + @Produces(MediaType.APPLICATION_JSON) + public String getHello() { + return "# Bonjour'\\nIndiquez-moi la RCT sur laquelle vous souhaitez faire des recherches ..."; + } + + @GET + @Path("/rct/{itemId}") + @Produces(MediaType.APPLICATION_JSON) + public Response getRctById(@PathParam("itemId") String itemId) { + + if (itemId == null) { + return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"itemId parameter is required\"}").build(); + } + + DriverManager.setLoginTimeout(5); // Set timeout to 5 seconds + + try (DatabaseConnectDOTSOFT databaseConnection = new DatabaseConnectDOTSOFT("omni")) { + String call = "{ call fbe_hdpos.chatrct_prompt_rct(?, ?) }"; + + logger.info(call); + + try (CallableStatement callableStatement = databaseConnection.getConnection().prepareCall(call)) { + // Set input parameters + callableStatement.setString(1, itemId); + + // Set output parameters + callableStatement.registerOutParameter(2, Types.CLOB); + + // Execute the stored procedure + callableStatement.execute(); + + // Retrieve results + Clob resultClob = callableStatement.getClob(2); + String result = resultClob.getSubString(1, (int) resultClob.length()); + + ObjectMapper objectMapper = new ObjectMapper(); + String jsonResponse = objectMapper.writeValueAsString(result); + + return Response.ok(jsonResponse).build(); + } + } catch (SQLException e) { + e.printStackTrace(); + String errorResponse = "{\"error\":\"" + e.getMessage() + "\"}"; + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponse).build(); + } catch (JsonProcessingException e) { + e.printStackTrace(); // Gérer les exceptions correctement dans un environnement de production + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"Error processing JSON\"}").build(); + } + } + + @GET + @Path("/distributor/{distributorId}") + @Produces(MediaType.APPLICATION_JSON) + public Response getDistributorById( + @PathParam("distributorId") String distributorId, + @QueryParam("itemId") String itemId, + @QueryParam("produitId") String produitId) { + + if (distributorId == null) { + return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"distributorId parameter is required\"}").build(); + } + + if (itemId == null) { + return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"itemId parameter is required\"}").build(); + } + + DriverManager.setLoginTimeout(5); // Set timeout to 5 seconds + + try (DatabaseConnectDOTSOFT databaseConnection = new DatabaseConnectDOTSOFT("omni")) { + String call = "{ call fbe_hdpos.chatrct_prompt_distributor(?,?,?,?) }"; + + logger.info(call); + + try (CallableStatement callableStatement = databaseConnection.getConnection().prepareCall(call)) { + // Set input parameters + callableStatement.setString(1, distributorId); + callableStatement.setString(2, itemId); + callableStatement.setString(3, produitId); + + // Set output parameters + callableStatement.registerOutParameter(4, Types.CLOB); + + // Execute the stored procedure + callableStatement.execute(); + + // Retrieve results + Clob resultClob = callableStatement.getClob(4); + String result = resultClob.getSubString(1, (int) resultClob.length()); + + ObjectMapper objectMapper = new ObjectMapper(); + String jsonResponse = objectMapper.writeValueAsString(result); + + return Response.ok(jsonResponse).build(); + } + } catch (SQLException e) { + e.printStackTrace(); + String errorResponse = "{\"error\":\"" + e.getMessage() + "\"}"; + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponse).build(); + } catch (JsonProcessingException e) { + e.printStackTrace(); // Gérer les exceptions correctement dans un environnement de production + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"Error processing JSON\"}").build(); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/example/services/OrderService.java b/src/main/java/com/example/services/OrderService.java index 79a7bd1..2068de0 100644 --- a/src/main/java/com/example/services/OrderService.java +++ b/src/main/java/com/example/services/OrderService.java @@ -7,7 +7,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import java.sql.Date; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/src/main/java/com/example/services/ProximisService.java b/src/main/java/com/example/services/ProximisService.java index 88ba610..690bd95 100644 --- a/src/main/java/com/example/services/ProximisService.java +++ b/src/main/java/com/example/services/ProximisService.java @@ -1,8 +1,5 @@ package com.example.services; -import java.net.http.HttpClient; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -14,10 +11,12 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.WebTarget; import java.io.IOException; import java.io.InputStream; -import java.net.URI; import org.json.JSONObject; import org.slf4j.Logger; @@ -48,6 +47,9 @@ public class ProximisService { try (DatabaseConnectOBI databaseConnection = new DatabaseConnectOBI()) { String query = "SELECT authorization_value FROM obi.obi_param_access_token WHERE authorization_header = ?" + " and cloud_type = 'PROXIMIS' AND application = 'OBI_ACCESS_TOKEN' AND version = 'V2'"; + + logger.info(query); + PreparedStatement stmt = databaseConnection.getConnection().prepareStatement(query); stmt.setString(1, "Authorization"); @@ -61,28 +63,29 @@ public class ProximisService { if (bearerToken == null || bearerToken.isEmpty()) { return Response.status(Response.Status.NOT_FOUND).entity("{\"error\":\"Empty bearer token\"}").build(); } else { - HttpClient client = HttpClient.newHttpClient(); - HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create(url + "/project/fulfillment/" + orderCode)) + Client client = ClientBuilder.newClient(); + WebTarget target = client.target(url + "/project/fulfillment/" + orderCode); + Response response = target.request(MediaType.APPLICATION_JSON) .header("Authorization", bearerToken) - .GET() - .build(); + .get(); - HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); - - if (response.statusCode() == 200) { - JSONObject commonObject = new JSONObject(); - commonObject.put("urlApp", urlApp); - - JSONObject jsonResponse = new JSONObject(); - jsonResponse.put("common", commonObject); - jsonResponse.put("oms", new JSONObject(response.body())); - - return Response.ok(jsonResponse.toString()).build(); - } else if (response.statusCode() == 401) { - return Response.status(Response.Status.UNAUTHORIZED).entity("{\"error\":\"Invalid token\"}").build(); - } else { - return Response.status(Response.Status.NOT_FOUND).entity("{\"error\":\"Failed to get order detail\"}").build(); + try { + if (response.getStatus() == 200) { + JSONObject commonObject = new JSONObject(); + commonObject.put("urlApp", urlApp); + + JSONObject jsonResponse = new JSONObject(); + jsonResponse.put("common", commonObject); + jsonResponse.put("oms", new JSONObject(response.readEntity(String.class))); + + return Response.ok(jsonResponse.toString()).build(); + } else if (response.getStatus() == 401) { + return Response.status(Response.Status.UNAUTHORIZED).entity("{\"error\":\"Invalid token\"}").build(); + } else { + return Response.status(Response.Status.NOT_FOUND).entity("{\"error\":\"Failed to get order detail\"}").build(); + } + } catch (Exception e) { + return Response.serverError().entity("{\"error\":\"Failed to communicate with server\"}").build(); } } } catch (Exception e) { diff --git a/src/main/resources/db.properties b/src/main/resources/db.properties index 3930020..27f3483 100644 --- a/src/main/resources/db.properties +++ b/src/main/resources/db.properties @@ -2,16 +2,19 @@ dev.dotsoft.db.url=jdbc:oracle:thin:@v-aspd-b01-irdc.adic.lan:1521/MASPDI dev.dotsoft.db.oai.password=base dev.dotsoft.db.com02.password=B1Xto9pAbtBCOxuecG7W +dev.dotsoft.db.omni.password=k5.Omni.Paspdi # Pre-production DOTSOFT environment settings preprod.dotsoft.db.url=jdbc:oracle:thin:@v-aspd-b01-ii-d.adic.lan:1521/IASPDI preprod.dotsoft.db.oai.password=base preprod.dotsoft.db.com02.password=B1Xto9pAbtBCOxuecG7W +preprod.dotsoft.db.omni.password=k5.Omni.Paspdi # Production DOTSOFT environment settings prod.dotsoft.db.url=jdbc:oracle:thin:@v-aspd-b03-ip-d.adic.lan:1521/PASPDI prod.dotsoft.db.oai.password=base prod.dotsoft.db.com02.password=com20 +prod.dotsoft.db.omni.password=k5.Omni.Paspdi # XSTORE environment settings xstore.db.url=jdbc:oracle:thin:@HOST:1521/XSTORE diff --git a/src/main/resources/env.properties b/src/main/resources/env.properties index e30e658..40b8a7c 100644 --- a/src/main/resources/env.properties +++ b/src/main/resources/env.properties @@ -1,2 +1,2 @@ # Indicates the current environment (dev, preprod, prod, etc.). -environment=prod \ No newline at end of file +environment=preprod \ No newline at end of file -- 2.40.1 From ea076d238344156ae13e305befea901f420cfe1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9rik=20BENOIST?= Date: Tue, 20 Feb 2024 00:14:11 +0100 Subject: [PATCH 3/4] feat: chat-rct --- bruno/chatrct/PromptActions.bru | 16 + bruno/chatrct/PromptRCT.bru | 6 +- bruno/chatrct/PromptStore.bru | 18 + bruno/chatrct/RctForceCache.bru | 24 ++ bruno/chatrct/RctForceException.bru | 27 ++ .../com/example/services/ChatRctService.java | 360 +++++++++++++++++- .../com/example/services/StoreService.java | 6 +- 7 files changed, 444 insertions(+), 13 deletions(-) create mode 100644 bruno/chatrct/PromptActions.bru create mode 100644 bruno/chatrct/PromptStore.bru create mode 100644 bruno/chatrct/RctForceCache.bru create mode 100644 bruno/chatrct/RctForceException.bru diff --git a/bruno/chatrct/PromptActions.bru b/bruno/chatrct/PromptActions.bru new file mode 100644 index 0000000..8b05105 --- /dev/null +++ b/bruno/chatrct/PromptActions.bru @@ -0,0 +1,16 @@ +meta { + name: PromptActions + type: http + seq: 5 +} + +get { + url: {{host}}/hdpos/api/chatrct/actions?itemId=XY10000-08-3A&produitId=3700824 + body: none + auth: none +} + +query { + itemId: XY10000-08-3A + produitId: 3700824 +} diff --git a/bruno/chatrct/PromptRCT.bru b/bruno/chatrct/PromptRCT.bru index 3fc41e0..273dfdc 100644 --- a/bruno/chatrct/PromptRCT.bru +++ b/bruno/chatrct/PromptRCT.bru @@ -5,7 +5,11 @@ meta { } get { - url: {{host}}/hdpos/api/chatrct/rct/XY10000-08-3A + url: {{host}}/hdpos/api/chatrct/rct?itemId=XY10000-08-3A body: none auth: none } + +query { + itemId: XY10000-08-3A +} diff --git a/bruno/chatrct/PromptStore.bru b/bruno/chatrct/PromptStore.bru new file mode 100644 index 0000000..4f2f764 --- /dev/null +++ b/bruno/chatrct/PromptStore.bru @@ -0,0 +1,18 @@ +meta { + name: PromptStore + type: http + seq: 4 +} + +get { + url: {{host}}/hdpos/api/chatrct/store/4?storeId=4&distributorId=1&itemId=XY10000-08-3A&produitId=3700824 + body: none + auth: none +} + +query { + storeId: 4 + distributorId: 1 + itemId: XY10000-08-3A + produitId: 3700824 +} diff --git a/bruno/chatrct/RctForceCache.bru b/bruno/chatrct/RctForceCache.bru new file mode 100644 index 0000000..8b01b2b --- /dev/null +++ b/bruno/chatrct/RctForceCache.bru @@ -0,0 +1,24 @@ +meta { + name: RctForceCache + type: http + seq: 6 +} + +put { + url: {{host}}/hdpos/api/chatrct/rct/forceCache + body: json + auth: none +} + +body:json { + { + "itemId": "XY10000", + "comment": "Test FRED" + } + +} + +body:form-urlencoded { + itemId: 9999999 + comment: test +} diff --git a/bruno/chatrct/RctForceException.bru b/bruno/chatrct/RctForceException.bru new file mode 100644 index 0000000..dd17a1c --- /dev/null +++ b/bruno/chatrct/RctForceException.bru @@ -0,0 +1,27 @@ +meta { + name: RctForceException + type: http + seq: 7 +} + +put { + url: {{host}}/hdpos/api/chatrct/rct/forceException + body: json + auth: none +} + +body:json { + { + "id_produit":3700821, + "id_distrib":1, + "fdate":"20241220", + "forcer_cache":1, + "modul_trait":"HDPOS" + } + +} + +body:form-urlencoded { + itemId: 9999999 + comment: test +} diff --git a/src/main/java/com/example/services/ChatRctService.java b/src/main/java/com/example/services/ChatRctService.java index fffeec7..9166de4 100644 --- a/src/main/java/com/example/services/ChatRctService.java +++ b/src/main/java/com/example/services/ChatRctService.java @@ -3,10 +3,20 @@ package com.example.services; import java.sql.CallableStatement; import java.sql.Clob; import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.ws.rs.BadRequestException; +import javax.ws.rs.Consumes; import javax.ws.rs.GET; +import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; @@ -32,9 +42,9 @@ public class ChatRctService { } @GET - @Path("/rct/{itemId}") + @Path("/rct") @Produces(MediaType.APPLICATION_JSON) - public Response getRctById(@PathParam("itemId") String itemId) { + public Response getRctById(@QueryParam("itemId") String itemId) { if (itemId == null) { return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"itemId parameter is required\"}").build(); @@ -61,8 +71,11 @@ public class ChatRctService { Clob resultClob = callableStatement.getClob(2); String result = resultClob.getSubString(1, (int) resultClob.length()); + // Convert Unicode representations to emojis + String resultWithEmojis = convertUnicodeStrsToEmojis(result); + ObjectMapper objectMapper = new ObjectMapper(); - String jsonResponse = objectMapper.writeValueAsString(result); + String jsonResponse = objectMapper.writeValueAsString(resultWithEmojis); return Response.ok(jsonResponse).build(); } @@ -80,9 +93,9 @@ public class ChatRctService { @Path("/distributor/{distributorId}") @Produces(MediaType.APPLICATION_JSON) public Response getDistributorById( - @PathParam("distributorId") String distributorId, + @PathParam("distributorId") Integer distributorId, @QueryParam("itemId") String itemId, - @QueryParam("produitId") String produitId) { + @QueryParam("produitId") Integer produitId) { if (distributorId == null) { return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"distributorId parameter is required\"}").build(); @@ -101,9 +114,9 @@ public class ChatRctService { try (CallableStatement callableStatement = databaseConnection.getConnection().prepareCall(call)) { // Set input parameters - callableStatement.setString(1, distributorId); + callableStatement.setInt(1, distributorId); callableStatement.setString(2, itemId); - callableStatement.setString(3, produitId); + callableStatement.setInt(3, produitId); // Set output parameters callableStatement.registerOutParameter(4, Types.CLOB); @@ -115,8 +128,11 @@ public class ChatRctService { Clob resultClob = callableStatement.getClob(4); String result = resultClob.getSubString(1, (int) resultClob.length()); + // Convert Unicode representations to emojis + String resultWithEmojis = convertUnicodeStrsToEmojis(result); + ObjectMapper objectMapper = new ObjectMapper(); - String jsonResponse = objectMapper.writeValueAsString(result); + String jsonResponse = objectMapper.writeValueAsString(resultWithEmojis); return Response.ok(jsonResponse).build(); } @@ -128,5 +144,331 @@ public class ChatRctService { e.printStackTrace(); // Gérer les exceptions correctement dans un environnement de production return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"Error processing JSON\"}").build(); } - } + } + + @GET + @Path("/store/{storeId}") + @Produces(MediaType.APPLICATION_JSON) + public Response getStoreById( + @PathParam("storeId") Integer storeId, + @QueryParam("distributorId") Integer distributorId, + @QueryParam("itemId") String itemId, + @QueryParam("produitId") Integer produitId) { + + if (storeId == null) { + return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"storeId parameter is required\"}").build(); + } + + if (distributorId == null) { + return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"distributorId parameter is required\"}").build(); + } + + if (itemId == null) { + return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"itemId parameter is required\"}").build(); + } + + String ip = ""; + String enseigne = ""; + int vendable = -1; // error by default + int gerable = -1; // error by default + + DriverManager.setLoginTimeout(5); // Set timeout to 5 seconds + + try (DatabaseConnectDOTSOFT databaseConnection = new DatabaseConnectDOTSOFT("com02")) { + String ipQuery = "SELECT hsc.ip FROM com02.HOTLINE_STRUCTURE_CAISSE hsc WHERE hsc.ID_STRUCTURE = ? AND hsc.ID_CAISSE = 20"; + logger.info(ipQuery); + + PreparedStatement ipStatement = databaseConnection.getConnection().prepareStatement(ipQuery); + ipStatement.setInt(1, storeId); + ResultSet ipResultSet = ipStatement.executeQuery(); + + if (ipResultSet.next()) { + ip = ipResultSet.getString("ip"); + } + + String enseigneQuery = "SELECT xs.enseigne FROM omni.xst_structure xs WHERE xs.ID_STRUCTURE = ?"; + logger.info(enseigneQuery); + + PreparedStatement enseigneStatement = databaseConnection.getConnection().prepareStatement(enseigneQuery); + enseigneStatement.setInt(1, storeId); + ResultSet enseigneResultSet = enseigneStatement.executeQuery(); + + if (enseigneResultSet.next()) { + enseigne = enseigneResultSet.getString("enseigne"); + } + + } catch (SQLException e) { + e.printStackTrace(); + } + + logger.info("Try to connect on IP :" + ip); + + // if Ip address is not null and enseigne is not null + if (ip.length() > 0 && enseigne.length() > 0) { + try (DatabaseConnectXSTORE databaseConnection = new DatabaseConnectXSTORE(ip,"dtv")) { + String itemQuery = "SELECT COUNT(*) as gerable " + + "FROM dtv.ITM_ITEM " + + "WHERE ORGANIZATION_ID = 1 AND ITEM_ID = ?"; + + logger.info(itemQuery); + + try (PreparedStatement itemStatement = databaseConnection.getConnection().prepareStatement(itemQuery)) { + itemStatement.setString(1, itemId); + + ResultSet itemResultSet = itemStatement.executeQuery(); + + if (itemResultSet.next()) { + if (itemResultSet.getInt("gerable") > 0) + gerable = 1; + else + gerable = 0; + } + } + + String optionsQuery = "SELECT COUNT(*) as vendable " + + "FROM dtv.ITM_ITEM_OPTIONS " + + "WHERE ORGANIZATION_ID = 1 AND ITEM_ID = ? AND LEVEL_CODE = 'ENSEIGNE' AND LEVEL_VALUE = ? AND ITEM_AVAILABILITY_CODE = 'AVAILABLE'"; + + logger.info(optionsQuery); + + try (PreparedStatement optionsStatement = databaseConnection.getConnection().prepareStatement(optionsQuery)) { + optionsStatement.setString(1, itemId); + optionsStatement.setString(2, enseigne); + + ResultSet optionsResultSet = optionsStatement.executeQuery(); + + if (optionsResultSet.next()) { + if (optionsResultSet.getInt("vendable") > 0) + vendable = 1; + else + vendable = 0; + } + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + + if (vendable == -1) { + logger.info("Unable to determine vendable status for store " + storeId); + } + + try (DatabaseConnectDOTSOFT databaseConnection = new DatabaseConnectDOTSOFT("omni")) { + String call = "{ call fbe_hdpos.chatrct_prompt_store(?,?,?,?,?,?,?,?) }"; + + logger.info(call); + + try (CallableStatement callableStatement = databaseConnection.getConnection().prepareCall(call)) { + // Set input parameters + callableStatement.setInt(1, storeId); + callableStatement.setInt(2, distributorId); + callableStatement.setString(3, itemId); + callableStatement.setInt(4, produitId); + callableStatement.setString(5, enseigne); + callableStatement.setInt(6, gerable); + callableStatement.setInt(7, vendable); + + // Set output parameters + callableStatement.registerOutParameter(8, Types.CLOB); + + // Execute the stored procedure + callableStatement.execute(); + + // Retrieve results + Clob resultClob = callableStatement.getClob(8); + String result = resultClob.getSubString(1, (int) resultClob.length()); + + // Convert Unicode representations to emojis + String resultWithEmojis = convertUnicodeStrsToEmojis(result); + + ObjectMapper objectMapper = new ObjectMapper(); + String jsonResponse = objectMapper.writeValueAsString(resultWithEmojis); + + return Response.ok(jsonResponse).build(); + } + } catch (SQLException e) { + e.printStackTrace(); + String errorResponse = "{\"error\":\"" + e.getMessage() + "\"}"; + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponse).build(); + } catch (JsonProcessingException e) { + e.printStackTrace(); // Gérer les exceptions correctement dans un environnement de production + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"Error processing JSON\"}").build(); + } + } + + @PUT + @Path("/rct/forceCache") + @Consumes(MediaType.APPLICATION_JSON) + public Response putRctForceCache(Map request) { + String itemId = request.get("itemId"); + String comment = request.get("comment"); + + if (itemId == null) { + return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"itemId parameter is required\"}").build(); + } + + if (comment == null) { + return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"comment parameter is required\"}").build(); + } + + try (DatabaseConnectDOTSOFT databaseConnection = new DatabaseConnectDOTSOFT("omni")) { + String enableOutput = "begin dbms_output.enable; end;"; + try (CallableStatement callableStatement = databaseConnection.getConnection().prepareCall(enableOutput)) { + callableStatement.execute(); + } + + String call = "{ call p_xsto_itm_force_cache(?,?) }"; + + logger.info(call); + + try (CallableStatement callableStatement = databaseConnection.getConnection().prepareCall(call)) { + // Set input parameters + callableStatement.setString(1, itemId); + callableStatement.setString(2, comment); + + // Execute the stored procedure + callableStatement.execute(); + + Map result = new HashMap<>(); + + // Retrieve DBMS_OUTPUT + String getOutput = "begin dbms_output.get_line(?, ?); end;"; + try (CallableStatement outputCallableStatement = databaseConnection.getConnection().prepareCall(getOutput)) { + outputCallableStatement.registerOutParameter(1, Types.VARCHAR); + outputCallableStatement.registerOutParameter(2, Types.INTEGER); + + StringBuilder output = new StringBuilder(); + int status = 0; + do { + outputCallableStatement.execute(); + status = outputCallableStatement.getInt(2); + if (status == 0) { + output.append(outputCallableStatement.getString(1)); + } + } while (status == 0); + + // Add DBMS_OUTPUT to your result + result.put("output", output.toString()); + } + + ObjectMapper objectMapper = new ObjectMapper(); + String jsonResponse = objectMapper.writeValueAsString(result); + + return Response.ok(jsonResponse).build(); + } + } catch (SQLException e) { + e.printStackTrace(); + String errorResponse = "{\"error\":\"" + e.getMessage() + "\"}"; + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponse).build(); + } catch (JsonProcessingException e) { + e.printStackTrace(); // Gérer les exceptions correctement dans un environnement de production + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"Error processing JSON\"}").build(); + } + } + + @PUT + @Path("/rct/forceException") + @Consumes(MediaType.APPLICATION_JSON) + public Response putRctForceException(Map request) { + String id_produit_str = request.get("id_produit"); + String id_distrib_str = request.get("id_distrib"); + String fdate = request.get("fdate"); + String forcer_cache_str = request.get("forcer_cache"); + String modul_trait = request.get("modul_trait"); + + Long id_produit = Optional.ofNullable(id_produit_str) + .map(Long::parseLong) + .orElseThrow(() -> new BadRequestException("id_produit parameter is required")); + + Integer id_distrib = Optional.ofNullable(id_distrib_str) + .map(Integer::parseInt) + .orElseThrow(() -> new BadRequestException("id_distrib parameter is required")); + + Integer forcer_cache = Optional.ofNullable(forcer_cache_str) + .map(Integer::parseInt) + .orElseThrow(() -> new BadRequestException("forcer_cache parameter is required")); + + if (fdate == null) { + return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"fdate parameter is required\"}").build(); + } + + if (modul_trait == null) { + return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"modul_trait parameter is required\"}").build(); + } + + try (DatabaseConnectDOTSOFT databaseConnection = new DatabaseConnectDOTSOFT("omni")) { + String enableOutput = "begin dbms_output.enable; end;"; + try (CallableStatement callableStatement = databaseConnection.getConnection().prepareCall(enableOutput)) { + callableStatement.execute(); + } + + String call = "{ call p_xsto_itm_force_exception(?,?,?,?,?) }"; + + logger.info(call); + + try (CallableStatement callableStatement = databaseConnection.getConnection().prepareCall(call)) { + // Set input parameters + callableStatement.setLong(1, id_produit); + callableStatement.setInt(2, id_distrib); + callableStatement.setString(3, fdate); + callableStatement.setInt(4, forcer_cache); + callableStatement.setString(5, modul_trait); + + // Execute the stored procedure + callableStatement.execute(); + + Map result = new HashMap<>(); + + // Retrieve DBMS_OUTPUT + String getOutput = "begin dbms_output.get_line(?, ?); end;"; + try (CallableStatement outputCallableStatement = databaseConnection.getConnection().prepareCall(getOutput)) { + outputCallableStatement.registerOutParameter(1, Types.VARCHAR); + outputCallableStatement.registerOutParameter(2, Types.INTEGER); + StringBuilder output = new StringBuilder(); + int status = 0; + do { + outputCallableStatement.execute(); + status = outputCallableStatement.getInt(2); + if (status == 0) { + output.append(outputCallableStatement.getString(1)); + } + } while (status == 0); + + // Add DBMS_OUTPUT to your result + result.put("output", output.toString()); + } + + ObjectMapper objectMapper = new ObjectMapper(); + String jsonResponse = objectMapper.writeValueAsString(result); + + return Response.ok(jsonResponse).build(); + } + } catch (SQLException e) { + e.printStackTrace(); + String errorResponse = "{\"error\":\"" + e.getMessage() + "\"}"; + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponse).build(); + } catch (JsonProcessingException e) { + e.printStackTrace(); // Gérer les exceptions correctement dans un environnement de production + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{\"error\":\"Error processing JSON\"}").build(); + } + } + + public static String convertUnicodeStrsToEmojis(String str) { + Pattern pattern = Pattern.compile("U\\+[0-9A-Fa-f]+"); + Matcher matcher = pattern.matcher(str); + StringBuffer sb = new StringBuffer(); + while (matcher.find()) { + String unicodeStr = matcher.group(); + String emoji = convertUnicodeStrToEmoji(unicodeStr); + matcher.appendReplacement(sb, emoji); + } + matcher.appendTail(sb); + return sb.toString(); + } + + public static String convertUnicodeStrToEmoji(String unicodeStr) { + String[] parts = unicodeStr.split("\\+"); + int unicodeInt = Integer.parseInt(parts[1], 16); + return new String(Character.toChars(unicodeInt)); + } } \ No newline at end of file diff --git a/src/main/java/com/example/services/StoreService.java b/src/main/java/com/example/services/StoreService.java index 2ab56ed..3ece428 100644 --- a/src/main/java/com/example/services/StoreService.java +++ b/src/main/java/com/example/services/StoreService.java @@ -179,12 +179,12 @@ public class StoreService { " AND hsc2.id_caisse BETWEEN 20 AND 39) AS caisses," + " REPLACE(REPLACE(TRIM(st.adresse1), chr(10), ''), chr(13), '') AS adresse," + " axs.date_stock as date_migration" + - " FROM COM02.structure st" + + " FROM com02.STRUCTURE st" + + " JOIN omni.ASPD_XSTO_STRUCTURE axs ON st.ID_STRUCTURE = axs.ID_STRUCTURE" + " JOIN com02.PARAM_PAYS pp ON pp.id_pays = st.id_pays" + " LEFT OUTER JOIN mobretail.mp_etab_param metabp ON metabp.id_etab = st.id_structure" + " LEFT OUTER JOIN mobretail.mr_photo mpprinc ON mpprinc.id_photo = metabp.id_photo_principale" + - " LEFT OUTER JOIN omni.ASPD_XSTO_STRUCTURE axs ON st.ID_STRUCTURE = axs.ID_STRUCTURE" + - " WHERE axs.date_stock is not null AND st.ID_NIVEAU=4 AND st.STATUT=2 AND st.id_canal_distribution = 1 and st.magasin_demo = 0" + + " WHERE axs.date_stock is not null AND st.id_niveau=4 AND st.statut=2 AND st.id_canal_distribution = 1" + " ORDER BY st.id_structure"; logger.info(query); -- 2.40.1 From 98df411ea21d87a58607e4434926094531a45d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9rik=20BENOIST?= Date: Tue, 20 Feb 2024 21:41:01 +0100 Subject: [PATCH 4/4] feat: chat-rct --- src/main/resources/env.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/env.properties b/src/main/resources/env.properties index 40b8a7c..e30e658 100644 --- a/src/main/resources/env.properties +++ b/src/main/resources/env.properties @@ -1,2 +1,2 @@ # Indicates the current environment (dev, preprod, prod, etc.). -environment=preprod \ No newline at end of file +environment=prod \ No newline at end of file -- 2.40.1