feat: small modifications
parent
04c854af2f
commit
3c1ccc4a2c
|
|
@ -4,6 +4,7 @@ import com.example.services.item.Item;
|
|||
import com.example.services.item.ItemDetails;
|
||||
import com.example.services.item.ItemOption;
|
||||
import com.example.services.item.ItemPrices;
|
||||
import com.example.services.item.ItemStock;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
|
|
@ -112,7 +113,6 @@ public class ItemService {
|
|||
item.setCreateUserId(resultSet.getString("CREATE_USER_ID"));
|
||||
item.setUpdateDate(resultSet.getDate("UPDATE_DATE"));
|
||||
item.setUpdateUserId(resultSet.getString("UPDATE_USER_ID"));
|
||||
item.setRecordState(resultSet.getString("RECORD_STATE"));
|
||||
|
||||
return item;
|
||||
}
|
||||
|
|
@ -169,6 +169,7 @@ public class ItemService {
|
|||
List<Item> itemList = new ArrayList<>();
|
||||
List<ItemOption> itemOptionList = new ArrayList<>();
|
||||
List<ItemPrices> itemPricesList = new ArrayList<>();
|
||||
List<ItemStock> itemStockList = new ArrayList<>();
|
||||
|
||||
try (DatabaseConnectXSTORE databaseConnection = new DatabaseConnectXSTORE(dbHost,"dtv")) {
|
||||
// Item section
|
||||
|
|
@ -231,6 +232,26 @@ public class ItemService {
|
|||
itemDetails.setItemPrices(itemPricesList);
|
||||
}
|
||||
}
|
||||
|
||||
// item stock section
|
||||
String ItemStockQuery = "SELECT organization_id,rtl_loc_id,inv_location_id,bucket_id,item_id, unitcount,inventory_value,create_date, create_user_id,update_date , update_user_id " +
|
||||
"FROM dtv.inv_stock_ledger_acct " +
|
||||
"WHERE organization_id = 1 AND item_id LIKE ?";
|
||||
|
||||
logger.info(ItemStockQuery);
|
||||
try (PreparedStatement itemStockStatement = databaseConnection.getConnection().prepareStatement(ItemStockQuery)) {
|
||||
// Concatenate % to parameter itemId
|
||||
itemStockStatement.setString(1, itemId + "%");
|
||||
|
||||
try (ResultSet itemStockResultSet = itemStockStatement.executeQuery()) {
|
||||
while (itemStockResultSet.next()) {
|
||||
ItemStock itemStock = mapResultSetToItemStockDetails(itemStockResultSet);
|
||||
itemStockList.add(itemStock);
|
||||
}
|
||||
|
||||
itemDetails.setItemStock(itemStockList);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
// Handle exceptions correctly in a production environment
|
||||
|
|
@ -294,4 +315,23 @@ public class ItemService {
|
|||
|
||||
return itemPrices;
|
||||
}
|
||||
|
||||
private ItemStock mapResultSetToItemStockDetails(ResultSet resultSet) throws SQLException {
|
||||
|
||||
ItemStock itemStock = new ItemStock();
|
||||
|
||||
itemStock.setOrganizationId(resultSet.getString("ORGANIZATION_ID"));
|
||||
itemStock.setRtlLocId(resultSet.getString("RTL_LOC_ID"));
|
||||
itemStock.setInvLocationId(resultSet.getString("INV_LOCATION_ID"));
|
||||
itemStock.setBucketId(resultSet.getString("BUCKET_ID"));
|
||||
itemStock.setItemId(resultSet.getString("ITEM_ID"));
|
||||
itemStock.setUnitCount(resultSet.getInt("UNITCOUNT"));
|
||||
itemStock.setInventoryValue(resultSet.getDouble("INVENTORY_VALUE"));
|
||||
itemStock.setCreateDate(resultSet.getDate("CREATE_DATE"));
|
||||
itemStock.setCreateUserId(resultSet.getString("CREATE_USER_ID"));
|
||||
itemStock.setUpdateDate(resultSet.getDate("UPDATE_DATE"));
|
||||
itemStock.setUpdateUserId(resultSet.getString("UPDATE_USER_ID"));
|
||||
|
||||
return itemStock;
|
||||
}
|
||||
}
|
||||
|
|
@ -33,7 +33,6 @@ import java.text.SimpleDateFormat;
|
|||
private String createUserId;
|
||||
private Date updateDate;
|
||||
private String updateUserId;
|
||||
private String recordState;
|
||||
|
||||
// Constructeur par défaut
|
||||
public Item() {
|
||||
|
|
@ -251,11 +250,14 @@ import java.text.SimpleDateFormat;
|
|||
}
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public String getCreateUserId() {
|
||||
if (createUserId == null) {
|
||||
return "";
|
||||
}
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
|
|
@ -277,18 +279,13 @@ import java.text.SimpleDateFormat;
|
|||
}
|
||||
|
||||
public String getUpdateUserId() {
|
||||
if (updateUserId == null) {
|
||||
return "";
|
||||
}
|
||||
return updateUserId;
|
||||
}
|
||||
|
||||
public void setUpdateUserId(String updateUserId) {
|
||||
this.updateUserId = updateUserId;
|
||||
}
|
||||
|
||||
public String getRecordState() {
|
||||
return recordState;
|
||||
}
|
||||
|
||||
public void setRecordState(String recordState) {
|
||||
this.recordState = recordState;
|
||||
}
|
||||
}
|
||||
|
|
@ -6,15 +6,17 @@ public class ItemDetails {
|
|||
private List<Item> items;
|
||||
private List<ItemOption> itemOptions;
|
||||
private List<ItemPrices> itemPrices;
|
||||
private List<ItemStock> itemStock;
|
||||
|
||||
public ItemDetails() {
|
||||
// Default constructor required for JSON deserialization
|
||||
}
|
||||
|
||||
public ItemDetails(List<Item> items, List<ItemOption> itemOptions, List<ItemPrices> itemPrices) {
|
||||
public ItemDetails(List<Item> items, List<ItemOption> itemOptions, List<ItemPrices> itemPrices, List<ItemStock> itemStocks) {
|
||||
this.items = items;
|
||||
this.itemOptions = itemOptions;
|
||||
this.itemPrices = itemPrices;
|
||||
this.itemStock = itemStocks;
|
||||
}
|
||||
|
||||
public List<Item> getItems() {
|
||||
|
|
@ -40,4 +42,12 @@ public class ItemDetails {
|
|||
public void setItemPrices(List<ItemPrices> itemPrices) {
|
||||
this.itemPrices = itemPrices;
|
||||
}
|
||||
|
||||
public List<ItemStock> getItemStock() {
|
||||
return itemStock;
|
||||
}
|
||||
|
||||
public void setItemStock(List<ItemStock> itemStocks) {
|
||||
this.itemStock = itemStocks;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,6 +93,9 @@ public class ItemOption {
|
|||
}
|
||||
|
||||
public String getCreateUserId() {
|
||||
if (createUserId == null) {
|
||||
return "";
|
||||
}
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
|
|
@ -114,6 +117,9 @@ public class ItemOption {
|
|||
}
|
||||
|
||||
public String getUpdateUserId() {
|
||||
if (updateUserId == null) {
|
||||
return "";
|
||||
}
|
||||
return updateUserId;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -129,6 +129,9 @@ public class ItemPrices {
|
|||
}
|
||||
|
||||
public String getCreateUserId() {
|
||||
if (createUserId == null) {
|
||||
return "";
|
||||
}
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
|
|
@ -150,6 +153,9 @@ public class ItemPrices {
|
|||
}
|
||||
|
||||
public String getUpdateUserId() {
|
||||
if (updateUserId == null) {
|
||||
return "";
|
||||
}
|
||||
return updateUserId;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,122 @@
|
|||
package com.example.services.item;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class ItemStock {
|
||||
private String organizationId;
|
||||
private String rtlLocId;
|
||||
private String invLocationId;
|
||||
private String bucketId;
|
||||
private String itemId;
|
||||
private int unitCount;
|
||||
private double inventoryValue;
|
||||
private Date createDate;
|
||||
private String createUserId;
|
||||
private Date updateDate;
|
||||
private String updateUserId;
|
||||
|
||||
public String getOrganizationId() {
|
||||
return organizationId;
|
||||
}
|
||||
|
||||
public void setOrganizationId(String organizationId) {
|
||||
this.organizationId = organizationId;
|
||||
}
|
||||
|
||||
public String getRtlLocId() {
|
||||
return rtlLocId;
|
||||
}
|
||||
|
||||
public void setRtlLocId(String rtlLocId) {
|
||||
this.rtlLocId = rtlLocId;
|
||||
}
|
||||
|
||||
public String getInvLocationId() {
|
||||
return invLocationId;
|
||||
}
|
||||
|
||||
public void setInvLocationId(String invLocationId) {
|
||||
this.invLocationId = invLocationId;
|
||||
}
|
||||
|
||||
public String getBucketId() {
|
||||
return bucketId;
|
||||
}
|
||||
|
||||
public void setBucketId(String bucketId) {
|
||||
this.bucketId = bucketId;
|
||||
}
|
||||
|
||||
public String getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
public void setItemId(String itemId) {
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
public int getUnitCount() {
|
||||
return unitCount;
|
||||
}
|
||||
|
||||
public void setUnitCount(int unitCount) {
|
||||
this.unitCount = unitCount;
|
||||
}
|
||||
|
||||
public double getInventoryValue() {
|
||||
return inventoryValue;
|
||||
}
|
||||
|
||||
public void setInventoryValue(double inventoryValue) {
|
||||
this.inventoryValue = inventoryValue;
|
||||
}
|
||||
|
||||
public String getCreateDate() {
|
||||
if (createDate != null) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
return dateFormat.format(createDate);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public String getCreateUserId() {
|
||||
if (createUserId == null) {
|
||||
return "";
|
||||
}
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
public void setCreateUserId(String createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
|
||||
public String getUpdateDate() {
|
||||
if (updateDate != null) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
return dateFormat.format(updateDate);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public void setUpdateDate(Date updateDate) {
|
||||
this.updateDate = updateDate;
|
||||
}
|
||||
|
||||
public String getUpdateUserId() {
|
||||
if (updateUserId == null) {
|
||||
return "";
|
||||
}
|
||||
return updateUserId;
|
||||
}
|
||||
|
||||
public void setUpdateUserId(String updateUserId) {
|
||||
this.updateUserId = updateUserId;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue