Compare commits

...

8 Commits
V1.0.1 ... main

38 changed files with 986 additions and 28 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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"
}
}

5
bruno/bruno.json Normal file
View File

@ -0,0 +1,5 @@
{
"version": "1",
"name": "hdpos",
"type": "collection"
}

View File

@ -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
}

View File

@ -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
}

View File

@ -0,0 +1,15 @@
meta {
name: PromptRCT
type: http
seq: 2
}
get {
url: {{host}}/hdpos/api/chatrct/rct?itemId=XY10000-08-3A
body: none
auth: none
}
query {
itemId: XY10000-08-3A
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

11
bruno/chatrct/hello.bru Normal file
View File

@ -0,0 +1,11 @@
meta {
name: Hello
type: http
seq: 1
}
get {
url: {{host}}/hdpos/api/chatrct/hello
body: none
auth: none
}

View File

@ -0,0 +1,4 @@
vars {
host: http://v-xsto-a01-iidc.adic.lan:8080
proximisHost: https://ikks.omn.proximis.com
}

View File

@ -0,0 +1,4 @@
vars {
host: http://localhost:8080
proximisHost: https://proximis-ikks-recette.stg.proximis.com
}

View File

@ -0,0 +1,11 @@
meta {
name: not sent
type: http
seq: 1
}
get {
url: {{host}}/hdpos/api/flux/bl/notsent
body: none
auth: none
}

View File

@ -0,0 +1,11 @@
meta {
name: hello 8080
type: http
seq: 1
}
get {
url: {{host}}/hdpos/api/hello
body: none
auth: none
}

15
bruno/items/items.bru Normal file
View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -0,0 +1,11 @@
meta {
name: GetByOrderId
type: http
seq: 1
}
get {
url: {{host}}/hdpos/api/obi/order/2845
body: none
auth: none
}

View File

@ -0,0 +1,11 @@
meta {
name: getOrderMessage
type: http
seq: 3
}
get {
url: {{host}}/hdpos/api/obi/order/2845/orderMessage
body: none
auth: none
}

View File

@ -0,0 +1,11 @@
meta {
name: projectFulfillment
type: http
seq: 1
}
get {
url: {{host}}/hdpos/api/proximis/project/fulfillment/1382020000066
body: none
auth: none
}

11
bruno/stores/All.bru Normal file
View File

@ -0,0 +1,11 @@
meta {
name: All
type: http
seq: 2
}
get {
url: {{host}}/hdpos/api/stores/
body: none
auth: none
}

16
bruno/stores/Log.bru Normal file
View File

@ -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
}

15
bruno/stores/Sequence.bru Normal file
View File

@ -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
}

View File

@ -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
}

View File

@ -0,0 +1,11 @@
meta {
name: StoreById
type: http
seq: 3
}
get {
url: {{host}}/hdpos/api/stores/4
body: none
auth: none
}

View File

@ -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
}

15
bruno/stores/Version.bru Normal file
View File

@ -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
}

11
bruno/stores/reload.bru Normal file
View File

@ -0,0 +1,11 @@
meta {
name: reload
type: http
seq: 8
}
get {
url: {{host}}/hdpos/api/stores/reload
body: none
auth: none
}

16
bruno/xadmin/Log.bru Normal file
View File

@ -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
}

View File

@ -0,0 +1,474 @@
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;
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")
@Produces(MediaType.APPLICATION_JSON)
public Response getRctById(@QueryParam("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());
// 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();
}
}
@GET
@Path("/distributor/{distributorId}")
@Produces(MediaType.APPLICATION_JSON)
public Response getDistributorById(
@PathParam("distributorId") Integer distributorId,
@QueryParam("itemId") String itemId,
@QueryParam("produitId") Integer 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.setInt(1, distributorId);
callableStatement.setString(2, itemId);
callableStatement.setInt(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());
// 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();
}
}
@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<String, String> 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<String, String> 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<String, String> 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<String, String> 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));
}
}

View File

@ -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;

View File

@ -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<String> 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) {

View File

@ -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);

View File

@ -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