- add fnsku in cosmos Product.java
parent
ee37ff3cf4
commit
76b4ddbc6f
|
@ -19,7 +19,7 @@ import retrofit2.Retrofit;
|
||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
import retrofit2.converter.gson.GsonConverterFactory;
|
||||||
|
|
||||||
public class RetrofitClient {
|
public class RetrofitClient {
|
||||||
private final static String BASE_URL = "https://portal.utopiaindustries.pk/uind/";
|
private final static String BASE_URL = "https://portal.utopiaindustries.pk/uind/";
|
||||||
// private final static String BASE_URL = "http://192.168.91.16:8080/uind/";
|
// private final static String BASE_URL = "http://192.168.91.16:8080/uind/";
|
||||||
|
|
||||||
private static Retrofit retrofit;
|
private static Retrofit retrofit;
|
||||||
|
|
|
@ -25,6 +25,8 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
public static final String PRODUCT_COLUMN_ITEM_PER_PACK = "itemPerPack";
|
public static final String PRODUCT_COLUMN_ITEM_PER_PACK = "itemPerPack";
|
||||||
public static final String PRODUCT_COLUMN_INVENTORY = "inventory";
|
public static final String PRODUCT_COLUMN_INVENTORY = "inventory";
|
||||||
public static final String PRODUCT_COLUMN_CATEGORY = "category";
|
public static final String PRODUCT_COLUMN_CATEGORY = "category";
|
||||||
|
public static final String PRODUCT_COLUMN_FNSKU = "fnsku";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* dimension table
|
* dimension table
|
||||||
|
@ -94,6 +96,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
+ PRODUCT_COLUMN_ITEM_PER_PACK + " INTEGER,"
|
+ PRODUCT_COLUMN_ITEM_PER_PACK + " INTEGER,"
|
||||||
+ PRODUCT_COLUMN_INVENTORY + " INTEGER,"
|
+ PRODUCT_COLUMN_INVENTORY + " INTEGER,"
|
||||||
+ PRODUCT_COLUMN_CATEGORY + " TEXT,"
|
+ PRODUCT_COLUMN_CATEGORY + " TEXT,"
|
||||||
|
+ PRODUCT_COLUMN_FNSKU + " TEXT,"
|
||||||
+ "PRIMARY KEY (" + PRODUCT_COLUMN_ASIN + ", " + PRODUCT_COLUMN_MARKETPLACE + ", " + PRODUCT_COLUMN_SKU + ")"
|
+ "PRIMARY KEY (" + PRODUCT_COLUMN_ASIN + ", " + PRODUCT_COLUMN_MARKETPLACE + ", " + PRODUCT_COLUMN_SKU + ")"
|
||||||
+ ")";
|
+ ")";
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ public class ProductRepository {
|
||||||
values.put(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_PACK, product.getItemPerPack());
|
values.put(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_PACK, product.getItemPerPack());
|
||||||
values.put(DatabaseHelper.PRODUCT_COLUMN_INVENTORY, product.getInventory());
|
values.put(DatabaseHelper.PRODUCT_COLUMN_INVENTORY, product.getInventory());
|
||||||
values.put(DatabaseHelper.PRODUCT_COLUMN_CATEGORY, product.getCategory());
|
values.put(DatabaseHelper.PRODUCT_COLUMN_CATEGORY, product.getCategory());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_FNSKU, product.getFnsku() );
|
||||||
database.insertWithOnConflict(DatabaseHelper.PRODUCT_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
database.insertWithOnConflict(DatabaseHelper.PRODUCT_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||||
}
|
}
|
||||||
database.setTransactionSuccessful();
|
database.setTransactionSuccessful();
|
||||||
|
@ -82,7 +83,7 @@ public class ProductRepository {
|
||||||
values.put(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_PACK, product.getItemPerPack());
|
values.put(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_PACK, product.getItemPerPack());
|
||||||
values.put(DatabaseHelper.PRODUCT_COLUMN_INVENTORY, product.getInventory());
|
values.put(DatabaseHelper.PRODUCT_COLUMN_INVENTORY, product.getInventory());
|
||||||
values.put(DatabaseHelper.PRODUCT_COLUMN_CATEGORY, product.getCategory());
|
values.put(DatabaseHelper.PRODUCT_COLUMN_CATEGORY, product.getCategory());
|
||||||
|
values.put(DatabaseHelper.PRODUCT_COLUMN_FNSKU, product.getFnsku());
|
||||||
database.insertWithOnConflict(DatabaseHelper.PRODUCT_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
database.insertWithOnConflict(DatabaseHelper.PRODUCT_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||||
close();
|
close();
|
||||||
});
|
});
|
||||||
|
@ -92,12 +93,12 @@ public class ProductRepository {
|
||||||
* Retrieve product by sku
|
* Retrieve product by sku
|
||||||
* */
|
* */
|
||||||
@SuppressLint("Range")
|
@SuppressLint("Range")
|
||||||
public List<Product> getProductBySkuOrAsin(String sku, String marketplace) {
|
public List<Product> getProductBySkuOrAsin(String fnsku, String marketplace) {
|
||||||
String selection = "(" + DatabaseHelper.PRODUCT_COLUMN_SKU + "=? OR " + PRODUCT_COLUMN_ASIN + "=? )";
|
String selection = DatabaseHelper.PRODUCT_COLUMN_FNSKU + "=?";
|
||||||
String[] selectionArgs = {sku,sku};
|
String[] selectionArgs = {fnsku};
|
||||||
if( marketplace != null && ! marketplace.isEmpty() ){
|
if( marketplace != null && ! marketplace.isEmpty() ){
|
||||||
selection += "AND " + PRODUCT_COLUMN_MARKETPLACE + "=?";
|
selection += " AND " + PRODUCT_COLUMN_MARKETPLACE + "=?";
|
||||||
selectionArgs = new String[]{ sku, sku, marketplace };
|
selectionArgs = new String[]{ fnsku, marketplace };
|
||||||
}
|
}
|
||||||
|
|
||||||
Cursor cursor = database.query(DatabaseHelper.PRODUCT_TABLE_NAME,
|
Cursor cursor = database.query(DatabaseHelper.PRODUCT_TABLE_NAME,
|
||||||
|
@ -125,7 +126,7 @@ public class ProductRepository {
|
||||||
product.setItemPerPack(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_PACK)));
|
product.setItemPerPack(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_PACK)));
|
||||||
product.setInventory(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_INVENTORY)));
|
product.setInventory(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_INVENTORY)));
|
||||||
product.setCategory(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_CATEGORY)));
|
product.setCategory(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_CATEGORY)));
|
||||||
|
product.setFnsku(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_FNSKU)));
|
||||||
products.add( product );
|
products.add( product );
|
||||||
} while ( cursor.moveToNext() );
|
} while ( cursor.moveToNext() );
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
@ -166,7 +167,7 @@ public class ProductRepository {
|
||||||
product.setItemPerPack(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_PACK)));
|
product.setItemPerPack(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_ITEM_PER_PACK)));
|
||||||
product.setInventory(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_INVENTORY)));
|
product.setInventory(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_INVENTORY)));
|
||||||
product.setCategory(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_CATEGORY)));
|
product.setCategory(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_CATEGORY)));
|
||||||
|
product.setFnsku(cursor.getString(cursor.getColumnIndex(DatabaseHelper.PRODUCT_COLUMN_FNSKU)));
|
||||||
cursor.close();
|
cursor.close();
|
||||||
close();
|
close();
|
||||||
return product;
|
return product;
|
||||||
|
|
|
@ -37,6 +37,8 @@ public class InspectionReportItem implements Serializable {
|
||||||
private List<InspectionItemCheckPoint> checkPoints;
|
private List<InspectionItemCheckPoint> checkPoints;
|
||||||
private List<InspectionItemDimension> dimensions;
|
private List<InspectionItemDimension> dimensions;
|
||||||
|
|
||||||
|
private String fnsku;
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -245,6 +247,14 @@ public class InspectionReportItem implements Serializable {
|
||||||
this.dateAdded = dateAdded;
|
this.dateAdded = dateAdded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getFnsku() {
|
||||||
|
return fnsku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFnsku(String fnsku) {
|
||||||
|
this.fnsku = fnsku;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
@ -19,6 +19,7 @@ public class Product implements Serializable {
|
||||||
private long itemPerPack;
|
private long itemPerPack;
|
||||||
private long inventory;
|
private long inventory;
|
||||||
private String category;
|
private String category;
|
||||||
|
private String fnsku;
|
||||||
|
|
||||||
public String getAsin() {
|
public String getAsin() {
|
||||||
return asin;
|
return asin;
|
||||||
|
@ -132,6 +133,14 @@ public class Product implements Serializable {
|
||||||
this.category = category;
|
this.category = category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getFnsku() {
|
||||||
|
return fnsku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFnsku(String fnsku) {
|
||||||
|
this.fnsku = fnsku;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Product{" +
|
return "Product{" +
|
||||||
|
@ -149,6 +158,7 @@ public class Product implements Serializable {
|
||||||
", itemPerPack=" + itemPerPack +
|
", itemPerPack=" + itemPerPack +
|
||||||
", inventory=" + inventory +
|
", inventory=" + inventory +
|
||||||
", category='" + category + '\'' +
|
", category='" + category + '\'' +
|
||||||
|
", fnsku='" + fnsku + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,16 +210,19 @@ public class CheckPointAdapter extends
|
||||||
imagePreview.setImageBitmap( bitmap );
|
imagePreview.setImageBitmap( bitmap );
|
||||||
}
|
}
|
||||||
|
|
||||||
InspectionCheckPoint cp = checkPoints.stream().filter(c ->c.getTitle().equalsIgnoreCase(defaultSelectedItem)).findFirst().get();
|
InspectionCheckPoint cp = checkPoints.stream().filter(c -> c.getTitle().equalsIgnoreCase(defaultSelectedItem)).findFirst().orElse( new InspectionCheckPoint());
|
||||||
// set standard
|
// set standard
|
||||||
InspectionCheckpointSku cpSku = checkpointSkus.stream()
|
if( checkpointSkus != null ){
|
||||||
.filter( inspectionCheckpointSku -> inspectionCheckpointSku.getCheckpointId() == cp.getId() )
|
InspectionCheckpointSku cpSku = checkpointSkus.stream()
|
||||||
.findFirst()
|
.filter( inspectionCheckpointSku -> inspectionCheckpointSku.getCheckpointId() == cp.getId() )
|
||||||
.orElse( new InspectionCheckpointSku() );
|
.findFirst()
|
||||||
if( cpSku.getStandard() != null && ! cpSku.getStandard().isEmpty() ){
|
.orElse( new InspectionCheckpointSku() );
|
||||||
standard.setText( cpSku.getStandard() );
|
if( cpSku.getStandard() != null && ! cpSku.getStandard().isEmpty() ){
|
||||||
|
standard.setText( cpSku.getStandard() );
|
||||||
|
} else {
|
||||||
|
((ViewGroup) standard.getParent() ).removeView( standard );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defectRecyclerView.setLayoutManager( new LinearLayoutManager( context ) );
|
defectRecyclerView.setLayoutManager( new LinearLayoutManager( context ) );
|
||||||
DefectsAdapter defectsAdapter = new DefectsAdapter(data, defectTypeOptions, defects, cp);
|
DefectsAdapter defectsAdapter = new DefectsAdapter(data, defectTypeOptions, defects, cp);
|
||||||
defectRecyclerView.setAdapter( defectsAdapter );
|
defectRecyclerView.setAdapter( defectsAdapter );
|
||||||
|
|
|
@ -108,7 +108,6 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
||||||
// marketplace
|
// marketplace
|
||||||
markerplace.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
markerplace.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
if( parent.getItemAtPosition( position ) != null ){
|
if( parent.getItemAtPosition( position ) != null ){
|
||||||
|
@ -116,7 +115,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
||||||
store.getReport().getItems().get(0).setMarketplace( marketplaceOption );
|
store.getReport().getItems().get(0).setMarketplace( marketplaceOption );
|
||||||
System.out.println( marketplaceOption );
|
System.out.println( marketplaceOption );
|
||||||
populateProductDataOnSelection(
|
populateProductDataOnSelection(
|
||||||
store.getReport().getItems().get(0).getSku(),
|
store.getReport().getItems().get(0).getFnsku(),
|
||||||
marketplaceOption,
|
marketplaceOption,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
@ -294,7 +293,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
||||||
if( v.getId() == R.id.search_sku_btn ){
|
if( v.getId() == R.id.search_sku_btn ){
|
||||||
if( sku.getText() != null ){
|
if( sku.getText() != null ){
|
||||||
populateProductDataOnSelection( sku.getText().toString(), "", true );
|
populateProductDataOnSelection( sku.getText().toString(), "", true );
|
||||||
populateSkuCheckpointsParams( sku.getText().toString() );
|
populateSkuCheckpointsParams( store.getReport().getItems().get(0).getSku() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( v.getId() == R.id.scan_sku_btn ){
|
if( v.getId() == R.id.scan_sku_btn ){
|
||||||
|
@ -318,15 +317,16 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateProductDataOnSelection( String sku, String marketplace , boolean populateMarketplace){
|
private void populateProductDataOnSelection( String fnsku, String marketplace , boolean populateMarketplace){
|
||||||
// setting the product details
|
// setting the product details
|
||||||
if( sku != null ){
|
if( fnsku != null ){
|
||||||
String skuStr = sku.trim();
|
String fnskuStr = fnsku.trim();
|
||||||
List<Product> products = new ProductRepository( getContext() ).getProductBySkuOrAsin( skuStr, marketplace );
|
List<Product> products = new ProductRepository( getContext() ).getProductBySkuOrAsin( fnskuStr, marketplace );
|
||||||
System.out.println( products );
|
System.out.println( products );
|
||||||
Product product = products.stream().findFirst().orElse( new Product() );
|
Product product = products.stream().findFirst().orElse( new Product() );
|
||||||
store.getReport().getItems().get(0).setSku( product.getSku() );
|
store.getReport().getItems().get(0).setSku( product.getSku() );
|
||||||
store.getReport().getItems().get(0).setAsin( product.getAsin() );
|
store.getReport().getItems().get(0).setAsin( product.getAsin() );
|
||||||
|
store.getReport().getItems().get(0).setFnsku( fnskuStr );
|
||||||
populateItem( products, populateMarketplace );
|
populateItem( products, populateMarketplace );
|
||||||
store.setProducts( products );
|
store.setProducts( products );
|
||||||
if( product.getCategory() != null ){
|
if( product.getCategory() != null ){
|
||||||
|
@ -365,6 +365,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
||||||
private void populateItem( List<Product> products , boolean populateMarketplace){
|
private void populateItem( List<Product> products , boolean populateMarketplace){
|
||||||
if( populateMarketplace ){
|
if( populateMarketplace ){
|
||||||
populateMarketplaces( products );
|
populateMarketplaces( products );
|
||||||
|
System.out.println("in");
|
||||||
}
|
}
|
||||||
populateModelNumber(products );
|
populateModelNumber(products );
|
||||||
populateTitle( products );
|
populateTitle( products );
|
||||||
|
|
Loading…
Reference in New Issue