AQL chart implementation

main
saad.siddiq 2025-03-10 15:50:58 +05:00
parent a0b3bcce24
commit 79d7f16c67
22 changed files with 1850 additions and 668 deletions

1
.idea/.name Normal file
View File

@ -0,0 +1 @@
QualityChecker

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetSelector">
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
</selectionStates>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

BIN
GitLOCStats.txt Normal file

Binary file not shown.

View File

@ -40,7 +40,7 @@
android:name=".ui.activities.MainActivity" android:name=".ui.activities.MainActivity"
android:exported="true" android:exported="true"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"> android:windowSoftInputMode="stateHidden|adjustPan">
</activity> </activity>
<activity <activity
android:name=".ui.activities.HomeActivity" android:name=".ui.activities.HomeActivity"

View File

@ -5,6 +5,7 @@ import com.utopiaindustries.qualitychecker.models.InspectionCheckPoint;
import com.utopiaindustries.qualitychecker.models.InspectionCheckpointSku; import com.utopiaindustries.qualitychecker.models.InspectionCheckpointSku;
import com.utopiaindustries.qualitychecker.models.InspectionDefect; import com.utopiaindustries.qualitychecker.models.InspectionDefect;
import com.utopiaindustries.qualitychecker.models.InspectionDimension; import com.utopiaindustries.qualitychecker.models.InspectionDimension;
import com.utopiaindustries.qualitychecker.models.InspectionLabelResponse;
import com.utopiaindustries.qualitychecker.models.InspectionReport; import com.utopiaindustries.qualitychecker.models.InspectionReport;
import com.utopiaindustries.qualitychecker.models.InspectionReportItem; import com.utopiaindustries.qualitychecker.models.InspectionReportItem;
import com.utopiaindustries.qualitychecker.models.ItemUnit; import com.utopiaindustries.qualitychecker.models.ItemUnit;
@ -92,4 +93,7 @@ public interface ApiService {
@GET( "rest/uic/inspection-report/inspection-sku-checkpoints" ) @GET( "rest/uic/inspection-report/inspection-sku-checkpoints" )
Call<List<InspectionCheckpointSku>> fetchSkuCheckpoints( ); Call<List<InspectionCheckpointSku>> fetchSkuCheckpoints( );
@GET("rest/uic/inspection-report/get-inspection-label")
Call<InspectionLabelResponse> fetchAllInspectionLabels();
} }

View File

@ -19,8 +19,8 @@ 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.90.27:8080/uind/";//"http://192.168.91.16:8080/uind/"; private final static String BASE_URL = "http://192.168.91.44:8081/uind/";//"http://192.168.91.44:8081/uind/";//"http://192.168.90.27:8080/uind/";//"http://192.168.91.16:8080/uind/";
private static Retrofit retrofit; private static Retrofit retrofit;

View File

@ -27,6 +27,21 @@ public class DatabaseHelper extends SQLiteOpenHelper {
public static final String PRODUCT_COLUMN_CATEGORY = "category"; public static final String PRODUCT_COLUMN_CATEGORY = "category";
public static final String PRODUCT_COLUMN_FNSKU = "fnsku"; public static final String PRODUCT_COLUMN_FNSKU = "fnsku";
//Table and Column for Inspection Label
public static final String INSPECTION_LABEL_TABLE_NAME = "inspection_label";
public static final String INSPECTION_LABEL_COLUMN_ID = "id";
public static final String INSPECTION_LABEL_COLUMN_MIN_LOT_SIZE = "minLotSize";
public static final String INSPECTION_LABEL_COLUMN_MAX_LOT_SIZE = "maxLotSize";
public static final String INSPECTION_LABEL_COLUMN_INSPECTION_LEVEL = "inspectionLevel";
public static final String INSPECTION_LABEL_COLUMN_SAMPLE_CODE = "sampleCode";
//Table and Column for Quality Label
public static final String QUALITY_LABEL_TABLE_NAME = "quality_label";
public static final String QUALITY_LABEL_COLUMN_ID = "id";
public static final String QUALITY_LABEL_COLUMN_SAMPLE_CODE = "sampleCode";
public static final String QUALITY_LABEL_COLUMN_SAMPLE_SIZE = "sampleSize";
public static final String QUALITY_LABEL_COLUMN_QUALITY_LEVEL = "qualityLevel";
public static final String QUALITY_LABEL_COLUMN_NO_ACCEPTED_DEFECTS = "noOfAcceptedDefects";
/* /*
* dimension table * dimension table
@ -153,6 +168,22 @@ public class DatabaseHelper extends SQLiteOpenHelper {
CHECKPOINT_SKU_STANDARD + " TEXT," + CHECKPOINT_SKU_STANDARD + " TEXT," +
"PRIMARY KEY (" + CHECKPOINT_SKU_SKU + ", " + CHECKPOINT_SKU_MARKETPLACE + ", " + CHECKPOINT_SKU_CHECKPOINT_ID + "))"; "PRIMARY KEY (" + CHECKPOINT_SKU_SKU + ", " + CHECKPOINT_SKU_MARKETPLACE + ", " + CHECKPOINT_SKU_CHECKPOINT_ID + "))";
String CREATE_INSPECTION_LABEL_TABLE = "CREATE TABLE " + INSPECTION_LABEL_TABLE_NAME + " (" +
INSPECTION_LABEL_COLUMN_ID + " INTEGER NOT NULL," +
INSPECTION_LABEL_COLUMN_MIN_LOT_SIZE + " INTEGER NOT NULL," +
INSPECTION_LABEL_COLUMN_MAX_LOT_SIZE + " INTEGER NOT NULL," +
INSPECTION_LABEL_COLUMN_INSPECTION_LEVEL + " INTEGER NOT NULL," +
INSPECTION_LABEL_COLUMN_SAMPLE_CODE + " TEXT NOT NULL )";
String CREATE_QUALITY_LABEL_TABLE = "CREATE TABLE " + QUALITY_LABEL_TABLE_NAME + " (" +
QUALITY_LABEL_COLUMN_ID + " INTEGER NOT NULL," +
QUALITY_LABEL_COLUMN_SAMPLE_CODE + " TEXT NOT NULL," +
QUALITY_LABEL_COLUMN_SAMPLE_SIZE + " INTEGER NOT NULL," +
QUALITY_LABEL_COLUMN_QUALITY_LEVEL + " REAL NOT NULL," +
QUALITY_LABEL_COLUMN_NO_ACCEPTED_DEFECTS + " INTEGER NOT NULL )";
db.execSQL( CREATE_PRODUCT_TABLE ); db.execSQL( CREATE_PRODUCT_TABLE );
db.execSQL( CREATE_INSPECTION_DIMENSION_TABLE ); db.execSQL( CREATE_INSPECTION_DIMENSION_TABLE );
db.execSQL( CREATE_CHECKPOINT_TABLE ); db.execSQL( CREATE_CHECKPOINT_TABLE );
@ -161,6 +192,8 @@ public class DatabaseHelper extends SQLiteOpenHelper {
db.execSQL( CREATE_REPORT_TABLE ); db.execSQL( CREATE_REPORT_TABLE );
db.execSQL( CREATE_DRAFT_REPORT_TABLE); db.execSQL( CREATE_DRAFT_REPORT_TABLE);
db.execSQL( CREATE_SKU_CHECKPOINT_TABLE ); db.execSQL( CREATE_SKU_CHECKPOINT_TABLE );
db.execSQL( CREATE_INSPECTION_LABEL_TABLE );
db.execSQL( CREATE_QUALITY_LABEL_TABLE );
} }
@Override @Override
@ -173,6 +206,8 @@ public class DatabaseHelper extends SQLiteOpenHelper {
db.execSQL( "DROP TABLE IF EXISTS " + REPORT_TABLE_NAME ); db.execSQL( "DROP TABLE IF EXISTS " + REPORT_TABLE_NAME );
db.execSQL( "DROP TABLE IF EXISTS " + DRAFT_REPORT_TABLE_NAME ); db.execSQL( "DROP TABLE IF EXISTS " + DRAFT_REPORT_TABLE_NAME );
db.execSQL( "DROP TABLE IF EXISTS " + CHECKPOINT_SKU_TABLE_NAME ); db.execSQL( "DROP TABLE IF EXISTS " + CHECKPOINT_SKU_TABLE_NAME );
db.execSQL( "DROP TABLE IF EXISTS " + INSPECTION_LABEL_TABLE_NAME );
db.execSQL( "DROP TABLE IF EXISTS " + QUALITY_LABEL_TABLE_NAME );
onCreate(db); onCreate(db);
} }
} }

View File

@ -0,0 +1,128 @@
package com.utopiaindustries.qualitychecker.db;
import static com.utopiaindustries.qualitychecker.db.DatabaseHelper.INSPECTION_LABEL_COLUMN_ID;
import static com.utopiaindustries.qualitychecker.db.DatabaseHelper.PRODUCT_COLUMN_ASIN;
import static com.utopiaindustries.qualitychecker.db.DatabaseHelper.QUALITY_LABEL_COLUMN_ID;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.utopiaindustries.qualitychecker.models.InspectionLabel;
import com.utopiaindustries.qualitychecker.models.Product;
import com.utopiaindustries.qualitychecker.models.QualityLabel;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class InspectionLabelRepository {
private final DatabaseHelper dbHelper;
private final SQLiteDatabase database;
private final ExecutorService executorService;
public InspectionLabelRepository(Context context) {
dbHelper = new DatabaseHelper(context);
database = dbHelper.getWritableDatabase();
executorService = Executors.newSingleThreadExecutor();
}
/*
* Insert list of inspection labels in batch
* */
public void insertInspectionLabels( List<InspectionLabel> inspectionLabels, List<QualityLabel> qualityLabels) {
executorService.execute(() -> {
database.beginTransaction();
try {
//Inspection Label
for (InspectionLabel inspectionLabel : inspectionLabels) {
ContentValues ivalues = new ContentValues();
ivalues.put(INSPECTION_LABEL_COLUMN_ID, inspectionLabel.getId());
ivalues.put(DatabaseHelper.INSPECTION_LABEL_COLUMN_MIN_LOT_SIZE, inspectionLabel.getMinLotSize());
ivalues.put(DatabaseHelper.INSPECTION_LABEL_COLUMN_MAX_LOT_SIZE, inspectionLabel.getMaxLotSize());
ivalues.put(DatabaseHelper.INSPECTION_LABEL_COLUMN_INSPECTION_LEVEL, inspectionLabel.getInspectionLevel());
ivalues.put(DatabaseHelper.INSPECTION_LABEL_COLUMN_SAMPLE_CODE, inspectionLabel.getSampleCode());
database.insertWithOnConflict(DatabaseHelper.INSPECTION_LABEL_TABLE_NAME, null, ivalues, SQLiteDatabase.CONFLICT_REPLACE);
}
//Quality Label
for (QualityLabel qualityLabel : qualityLabels) {
ContentValues qvalues = new ContentValues();
qvalues.put(QUALITY_LABEL_COLUMN_ID, qualityLabel.getId());
qvalues.put(DatabaseHelper.QUALITY_LABEL_COLUMN_SAMPLE_CODE, qualityLabel.getSampleCode());
qvalues.put(DatabaseHelper.QUALITY_LABEL_COLUMN_SAMPLE_SIZE, qualityLabel.getSampleSize());
qvalues.put(DatabaseHelper.QUALITY_LABEL_COLUMN_QUALITY_LEVEL, qualityLabel.getQualityLevel());
qvalues.put(DatabaseHelper.QUALITY_LABEL_COLUMN_NO_ACCEPTED_DEFECTS, qualityLabel.getNoOfAcceptedDefects());
database.insertWithOnConflict(DatabaseHelper.QUALITY_LABEL_TABLE_NAME, null, qvalues, SQLiteDatabase.CONFLICT_REPLACE);
}
database.setTransactionSuccessful();
} finally {
database.endTransaction();
close();
}
});
}
/*
* Get list of inspection labels from database
* */
public List<InspectionLabel> getInspectionLabels() {
List<InspectionLabel> inspectionLabels = new ArrayList<>();
Cursor cursor = database.query(DatabaseHelper.INSPECTION_LABEL_TABLE_NAME, new String[]{INSPECTION_LABEL_COLUMN_ID,
DatabaseHelper.INSPECTION_LABEL_COLUMN_MIN_LOT_SIZE, DatabaseHelper.INSPECTION_LABEL_COLUMN_MAX_LOT_SIZE,
DatabaseHelper.INSPECTION_LABEL_COLUMN_INSPECTION_LEVEL, DatabaseHelper.INSPECTION_LABEL_COLUMN_SAMPLE_CODE},
null, null, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
do {
InspectionLabel inspectionLabel = new InspectionLabel();
inspectionLabel.setId(cursor.getInt(0));
inspectionLabel.setMinLotSize(cursor.getInt(1));
inspectionLabel.setMaxLotSize(cursor.getInt(2));
inspectionLabel.setInspectionLevel(cursor.getInt(3));
inspectionLabel.setSampleCode(cursor.getString(4));
inspectionLabels.add(inspectionLabel);
} while (cursor.moveToNext());
cursor.close();
}
return inspectionLabels;
}
/*
* Get list of quality labels from database
* */
public List<QualityLabel> getQualityLabels() {
List<QualityLabel> qualityLabels = new ArrayList<>();
Cursor cursor = database.query(DatabaseHelper.QUALITY_LABEL_TABLE_NAME, new String[]{QUALITY_LABEL_COLUMN_ID,
DatabaseHelper.QUALITY_LABEL_COLUMN_SAMPLE_CODE, DatabaseHelper.QUALITY_LABEL_COLUMN_SAMPLE_SIZE,
DatabaseHelper.QUALITY_LABEL_COLUMN_QUALITY_LEVEL, DatabaseHelper.QUALITY_LABEL_COLUMN_NO_ACCEPTED_DEFECTS},
null, null, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
do {
QualityLabel qualityLabel = new QualityLabel();
qualityLabel.setId(cursor.getInt(0));
qualityLabel.setSampleCode(cursor.getString(1));
qualityLabel.setSampleSize(cursor.getInt(2));
qualityLabel.setQualityLevel(cursor.getDouble(3));
qualityLabel.setNoOfAcceptedDefects(cursor.getInt(4));
qualityLabels.add(qualityLabel);
} while (cursor.moveToNext());
cursor.close();
}
return qualityLabels;
}
/*
* Close the database
*/
public void close() {
dbHelper.close();
executorService.shutdown();
}
}

View File

@ -0,0 +1,65 @@
package com.utopiaindustries.qualitychecker.models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class InspectionLabel {
@SerializedName("id")
@Expose
private Integer id;
@SerializedName("minLotSize")
@Expose
private Integer minLotSize;
@SerializedName("maxLotSize")
@Expose
private Integer maxLotSize;
@SerializedName("inspectionLevel")
@Expose
private Integer inspectionLevel;
@SerializedName("sampleCode")
@Expose
private String sampleCode;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getMinLotSize() {
return minLotSize;
}
public void setMinLotSize(Integer minLotSize) {
this.minLotSize = minLotSize;
}
public Integer getMaxLotSize() {
return maxLotSize;
}
public void setMaxLotSize(Integer maxLotSize) {
this.maxLotSize = maxLotSize;
}
public Integer getInspectionLevel() {
return inspectionLevel;
}
public void setInspectionLevel(Integer inspectionLevel) {
this.inspectionLevel = inspectionLevel;
}
public String getSampleCode() {
return sampleCode;
}
public void setSampleCode(String sampleCode) {
this.sampleCode = sampleCode;
}
}

View File

@ -0,0 +1,33 @@
package com.utopiaindustries.qualitychecker.models;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class InspectionLabelResponse {
@SerializedName("qualityLabel")
@Expose
private List<QualityLabel> qualityLabel;
@SerializedName("inspectionLabel")
@Expose
private List<InspectionLabel> inspectionLabel;
public List<QualityLabel> getQualityLabel() {
return qualityLabel;
}
public void setQualityLabel(List<QualityLabel> qualityLabel) {
this.qualityLabel = qualityLabel;
}
public List<InspectionLabel> getInspectionLabel() {
return inspectionLabel;
}
public void setInspectionLabel(List<InspectionLabel> inspectionLabel) {
this.inspectionLabel = inspectionLabel;
}
}

View File

@ -31,12 +31,27 @@ public class InspectionReportItem implements Serializable {
private float packsSelected; private float packsSelected;
private float piecesSelected; private float piecesSelected;
private float checkedCartonsSelected; private float cartonWeight;
private float checkedPacksSelected; private float cartonLength;
private float checkedPiecesSelected; private float cartonHeight;
private float cartonWidth;
private float packWeight;
private float packWidth;
private float packLength;
private float packHeight;
private long sampleSize;
private long inspectionLevel;
private long minorQualityLevel;
private long majorQualityLevel;
private int aqlSampleSize;
private int checkedCartonsSelected;
private int checkedPacksSelected;
private int checkedPiecesSelected;
private String packingDetails; private String packingDetails;
private String sampleSize; //private String sampleSize;
private String dateAdded; private String dateAdded;
// wrapper // wrapper
private List<InspectionItemCheckPoint> checkPoints; private List<InspectionItemCheckPoint> checkPoints;
@ -236,11 +251,11 @@ public class InspectionReportItem implements Serializable {
this.piecesSelected = piecesSelected; this.piecesSelected = piecesSelected;
} }
public String getSampleSize() { public long getSampleSize() {
return sampleSize; return sampleSize;
} }
public void setSampleSize(String sampleSize) { public void setSampleSize(long sampleSize) {
this.sampleSize = sampleSize; this.sampleSize = sampleSize;
} }
@ -260,34 +275,129 @@ public class InspectionReportItem implements Serializable {
this.fnsku = fnsku; this.fnsku = fnsku;
} }
public float getCheckedCartonsSelected() { public int getCheckedCartonsSelected() {
return checkedCartonsSelected; return checkedCartonsSelected;
} }
public void setCheckedCartonsSelected(float checkedCartonsSelected) { public void setCheckedCartonsSelected(int checkedCartonsSelected) {
this.checkedCartonsSelected = checkedCartonsSelected; this.checkedCartonsSelected = checkedCartonsSelected;
} }
public float getCheckedPacksSelected() { public int getCheckedPacksSelected() {
return checkedPacksSelected; return checkedPacksSelected;
} }
public void setCheckedPacksSelected(float checkedPacksSelected) { public void setCheckedPacksSelected(int checkedPacksSelected) {
this.checkedPacksSelected = checkedPacksSelected; this.checkedPacksSelected = checkedPacksSelected;
} }
public float getCheckedPiecesSelected() { public int getCheckedPiecesSelected() {
return checkedPiecesSelected; return checkedPiecesSelected;
} }
public void setCheckedPiecesSelected(float checkedPiecesSelected) { public void setCheckedPiecesSelected(int checkedPiecesSelected) {
this.checkedPiecesSelected = checkedPiecesSelected; this.checkedPiecesSelected = checkedPiecesSelected;
} }
@NonNull public long getMajorQualityLevel() {
return majorQualityLevel;
}
public void setMajorQualityLevel(long majorQualityLevel) {
this.majorQualityLevel = majorQualityLevel;
}
public long getMinorQualityLevel() {
return minorQualityLevel;
}
public void setMinorQualityLevel(long minorQualityLevel) {
this.minorQualityLevel = minorQualityLevel;
}
public long getInspectionLevel() {
return inspectionLevel;
}
public void setInspectionLevel(long inspectionLevel) {
this.inspectionLevel = inspectionLevel;
}
public float getPackHeight() {
return packHeight;
}
public void setPackHeight(float packHeight) {
this.packHeight = packHeight;
}
public float getPackLength() {
return packLength;
}
public void setPackLength(float packLength) {
this.packLength = packLength;
}
public float getPackWidth() {
return packWidth;
}
public void setPackWidth(float packWidth) {
this.packWidth = packWidth;
}
public float getPackWeight() {
return packWeight;
}
public void setPackWeight(float packWeight) {
this.packWeight = packWeight;
}
public float getCartonWidth() {
return cartonWidth;
}
public void setCartonWidth(float cartonWidth) {
this.cartonWidth = cartonWidth;
}
public float getCartonHeight() {
return cartonHeight;
}
public void setCartonHeight(float cartonHeight) {
this.cartonHeight = cartonHeight;
}
public float getCartonLength() {
return cartonLength;
}
public void setCartonLength(float cartonLength) {
this.cartonLength = cartonLength;
}
public float getCartonWeight() {
return cartonWeight;
}
public void setCartonWeight(float cartonWeight) {
this.cartonWeight = cartonWeight;
}
public int getAqlSampleSize() {
return aqlSampleSize;
}
public void setAqlSampleSize(int aqlSampleSize) {
this.aqlSampleSize = aqlSampleSize;
}
@Override @Override
public String toString() { public String toString() {
return "InspectionAuditReportItem{" + return "InspectionReportItem{" +
"id=" + id + "id=" + id +
", reportId=" + reportId + ", reportId=" + reportId +
", asin='" + asin + '\'' + ", asin='" + asin + '\'' +
@ -301,8 +411,35 @@ public class InspectionReportItem implements Serializable {
", smColor='" + smColor + '\'' + ", smColor='" + smColor + '\'' +
", smSize='" + smSize + '\'' + ", smSize='" + smSize + '\'' +
", smItemName='" + smItemName + '\'' + ", smItemName='" + smItemName + '\'' +
", orderNumber='" + orderNumber + '\'' +
", article='" + article + '\'' +
", totalPresentPieces=" + totalPresentPieces +
", totalPresentPacks=" + totalPresentPacks +
", totalPresentCartons=" + totalPresentCartons +
", cartonsSelected=" + cartonsSelected +
", packsSelected=" + packsSelected +
", piecesSelected=" + piecesSelected +
", cartonWeight=" + cartonWeight +
", cartonLength=" + cartonLength +
", cartonHeight=" + cartonHeight +
", cartonWidth=" + cartonWidth +
", packWeight=" + packWeight +
", packWidth=" + packWidth +
", packLength=" + packLength +
", packHeight=" + packHeight +
", sampleSize=" + sampleSize +
", inspectionLevel=" + inspectionLevel +
", minorQualityLevel=" + minorQualityLevel +
", majorQualityLevel=" + majorQualityLevel +
", aqlSampleSize=" + aqlSampleSize +
", checkedCartonsSelected=" + checkedCartonsSelected +
", checkedPacksSelected=" + checkedPacksSelected +
", checkedPiecesSelected=" + checkedPiecesSelected +
", packingDetails='" + packingDetails + '\'' +
", dateAdded='" + dateAdded + '\'' +
", checkPoints=" + checkPoints + ", checkPoints=" + checkPoints +
", dimensions=" + dimensions + ", dimensions=" + dimensions +
", fnsku='" + fnsku + '\'' +
'}'; '}';
} }
} }

View File

@ -0,0 +1,65 @@
package com.utopiaindustries.qualitychecker.models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class QualityLabel {
@SerializedName("id")
@Expose
private Integer id;
@SerializedName("sampleCode")
@Expose
private String sampleCode;
@SerializedName("sampleSize")
@Expose
private Integer sampleSize;
@SerializedName("qualityLevel")
@Expose
private Double qualityLevel;
@SerializedName("noOfAcceptedDefects")
@Expose
private Integer noOfAcceptedDefects;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getSampleCode() {
return sampleCode;
}
public void setSampleCode(String sampleCode) {
this.sampleCode = sampleCode;
}
public Integer getSampleSize() {
return sampleSize;
}
public void setSampleSize(Integer sampleSize) {
this.sampleSize = sampleSize;
}
public Double getQualityLevel() {
return qualityLevel;
}
public void setQualityLevel(Double qualityLevel) {
this.qualityLevel = qualityLevel;
}
public Integer getNoOfAcceptedDefects() {
return noOfAcceptedDefects;
}
public void setNoOfAcceptedDefects(Integer noOfAcceptedDefects) {
this.noOfAcceptedDefects = noOfAcceptedDefects;
}
}

View File

@ -0,0 +1,5 @@
package com.utopiaindustries.qualitychecker.models.callback;
public interface SaveInspectionLabelCallBack extends SaveCallback {
}

View File

@ -12,6 +12,7 @@ import com.utopiaindustries.qualitychecker.db.CheckpointRepository;
import com.utopiaindustries.qualitychecker.db.DefectRepository; import com.utopiaindustries.qualitychecker.db.DefectRepository;
import com.utopiaindustries.qualitychecker.db.DimensionRepository; import com.utopiaindustries.qualitychecker.db.DimensionRepository;
import com.utopiaindustries.qualitychecker.db.InspectionCheckpointSkuRepository; import com.utopiaindustries.qualitychecker.db.InspectionCheckpointSkuRepository;
import com.utopiaindustries.qualitychecker.db.InspectionLabelRepository;
import com.utopiaindustries.qualitychecker.db.ItemRepository; import com.utopiaindustries.qualitychecker.db.ItemRepository;
import com.utopiaindustries.qualitychecker.db.ProductRepository; import com.utopiaindustries.qualitychecker.db.ProductRepository;
import com.utopiaindustries.qualitychecker.db.ReportRepository; import com.utopiaindustries.qualitychecker.db.ReportRepository;
@ -21,6 +22,7 @@ import com.utopiaindustries.qualitychecker.models.InspectionDefect;
import com.utopiaindustries.qualitychecker.models.InspectionDimension; import com.utopiaindustries.qualitychecker.models.InspectionDimension;
import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint; import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint;
import com.utopiaindustries.qualitychecker.models.InspectionItemDefect; import com.utopiaindustries.qualitychecker.models.InspectionItemDefect;
import com.utopiaindustries.qualitychecker.models.InspectionLabelResponse;
import com.utopiaindustries.qualitychecker.models.InspectionReport; import com.utopiaindustries.qualitychecker.models.InspectionReport;
import com.utopiaindustries.qualitychecker.models.InspectionReportWrapper; import com.utopiaindustries.qualitychecker.models.InspectionReportWrapper;
import com.utopiaindustries.qualitychecker.models.ItemUnit; import com.utopiaindustries.qualitychecker.models.ItemUnit;
@ -29,6 +31,7 @@ import com.utopiaindustries.qualitychecker.models.callback.SaveCheckpointCallbac
import com.utopiaindustries.qualitychecker.models.callback.SaveDefectCallback; import com.utopiaindustries.qualitychecker.models.callback.SaveDefectCallback;
import com.utopiaindustries.qualitychecker.models.callback.SaveDimensionCallback; import com.utopiaindustries.qualitychecker.models.callback.SaveDimensionCallback;
import com.utopiaindustries.qualitychecker.models.callback.SaveDraftReportCallback; import com.utopiaindustries.qualitychecker.models.callback.SaveDraftReportCallback;
import com.utopiaindustries.qualitychecker.models.callback.SaveInspectionLabelCallBack;
import com.utopiaindustries.qualitychecker.models.callback.SaveItemCallback; import com.utopiaindustries.qualitychecker.models.callback.SaveItemCallback;
import com.utopiaindustries.qualitychecker.models.callback.SaveProductCallBack; import com.utopiaindustries.qualitychecker.models.callback.SaveProductCallBack;
import com.utopiaindustries.qualitychecker.models.callback.SaveReportCallback; import com.utopiaindustries.qualitychecker.models.callback.SaveReportCallback;
@ -275,6 +278,13 @@ public class InspectionReportService {
}).start(); }).start();
} }
public void fetchAndPopulateInspectionLabel( SaveInspectionLabelCallBack callback,
InspectionLabelRepository repository){
new Thread(() -> {
populateInspectionLabels( callback, repository );
}).start();
}
public void fetchAndPopulateDimensions( SaveDimensionCallback callback, public void fetchAndPopulateDimensions( SaveDimensionCallback callback,
DimensionRepository repository ){ DimensionRepository repository ){
new Thread(() -> { new Thread(() -> {
@ -338,6 +348,36 @@ public class InspectionReportService {
} }
); );
} }
private void populateInspectionLabels( SaveInspectionLabelCallBack callback,
InspectionLabelRepository repository ){
apiService.fetchAllInspectionLabels().enqueue(
new Callback<InspectionLabelResponse>() {
@Override
public void onResponse(Call<InspectionLabelResponse> call,
Response<InspectionLabelResponse> response) {
if (response.isSuccessful()) {
try {
System.out.println( response.body() );
callback.onSuccess();
assert response.body() != null;
repository.insertInspectionLabels( response.body().getInspectionLabel(), response.body().getQualityLabel() );
} catch ( Exception ex ){
callback.onFailure(new Exception( ex.getMessage() ) );
}
} else {
callback.onFailure(new Exception("API call failed with status code: " + response.code()));
}
}
@Override
public void onFailure(Call<InspectionLabelResponse> call, Throwable t) {
System.out.println(t);
callback.onFailure(t);
}
}
);
}
private void populateDimensions( SaveDimensionCallback callback, private void populateDimensions( SaveDimensionCallback callback,
DimensionRepository repository ){ DimensionRepository repository ){

View File

@ -34,6 +34,7 @@ import com.utopiaindustries.qualitychecker.db.CheckpointRepository;
import com.utopiaindustries.qualitychecker.db.DefectRepository; import com.utopiaindustries.qualitychecker.db.DefectRepository;
import com.utopiaindustries.qualitychecker.db.DimensionRepository; import com.utopiaindustries.qualitychecker.db.DimensionRepository;
import com.utopiaindustries.qualitychecker.db.InspectionCheckpointSkuRepository; import com.utopiaindustries.qualitychecker.db.InspectionCheckpointSkuRepository;
import com.utopiaindustries.qualitychecker.db.InspectionLabelRepository;
import com.utopiaindustries.qualitychecker.db.ItemRepository; import com.utopiaindustries.qualitychecker.db.ItemRepository;
import com.utopiaindustries.qualitychecker.db.ProductRepository; import com.utopiaindustries.qualitychecker.db.ProductRepository;
import com.utopiaindustries.qualitychecker.models.EmployeePhoto; import com.utopiaindustries.qualitychecker.models.EmployeePhoto;
@ -41,6 +42,7 @@ import com.utopiaindustries.qualitychecker.models.InspectionReport;
import com.utopiaindustries.qualitychecker.models.callback.SaveCheckpointCallback; import com.utopiaindustries.qualitychecker.models.callback.SaveCheckpointCallback;
import com.utopiaindustries.qualitychecker.models.callback.SaveDefectCallback; import com.utopiaindustries.qualitychecker.models.callback.SaveDefectCallback;
import com.utopiaindustries.qualitychecker.models.callback.SaveDimensionCallback; import com.utopiaindustries.qualitychecker.models.callback.SaveDimensionCallback;
import com.utopiaindustries.qualitychecker.models.callback.SaveInspectionLabelCallBack;
import com.utopiaindustries.qualitychecker.models.callback.SaveItemCallback; import com.utopiaindustries.qualitychecker.models.callback.SaveItemCallback;
import com.utopiaindustries.qualitychecker.models.callback.SaveProductCallBack; import com.utopiaindustries.qualitychecker.models.callback.SaveProductCallBack;
import com.utopiaindustries.qualitychecker.notification.NotificationHelper; import com.utopiaindustries.qualitychecker.notification.NotificationHelper;
@ -195,6 +197,7 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
fetchAndPopulateDefectsData(); fetchAndPopulateDefectsData();
fetchAndPopulateUnitsData(); fetchAndPopulateUnitsData();
fetchAndPopulateSkuCheckpointsData(); fetchAndPopulateSkuCheckpointsData();
fetchAndPopulateInspectionLevelData();
} else { } else {
Toast.makeText( this, "network not available", Toast.LENGTH_LONG ).show(); Toast.makeText( this, "network not available", Toast.LENGTH_LONG ).show();
} }
@ -267,6 +270,36 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
}, new ProductRepository( this ) ); }, new ProductRepository( this ) );
} }
/*
* fetch and update inspection label
* */
private void fetchAndPopulateInspectionLevelData() {
NotificationHelper.showProductNotification(
this,
"Utopia QA App",
"Fetching Inspection Label.");
inspectionReportService.fetchAndPopulateInspectionLabel( new SaveInspectionLabelCallBack() {
@Override
public void onSuccess() {
Toast.makeText( HomeActivity.this, "Inspection Labels successfully synced", Toast.LENGTH_LONG ).show();
NotificationHelper.showProductNotification(
HomeActivity.this,
"Utopia QA App",
"Inspection Labels successfully synced");
}
@Override
public void onFailure(Throwable throwable) {
Toast.makeText( HomeActivity.this, "Error in Inspection Labels syncing " + throwable.getMessage(), Toast.LENGTH_LONG ).show();
NotificationHelper.showProductNotification(
HomeActivity.this,
"Utopia QA App",
"Error in Inspection Labels syncing" );
}
}, new InspectionLabelRepository( this ) );
}
private void fetchAndPopulateDimensionsData(){ private void fetchAndPopulateDimensionsData(){
NotificationHelper.showProductNotification( this, NotificationHelper.showProductNotification( this,

View File

@ -69,16 +69,20 @@ public class ReportAdapter extends
// Format the date in 12-hour format // Format the date in 12-hour format
String formattedDateTime = displayDateFormat.format( date ); String formattedDateTime = displayDateFormat.format( date );
dateTv.setText( formattedDateTime ); dateTv.setText( formattedDateTime );
if( report.getReportResult().equalsIgnoreCase("FAILED") ){
status.setBackgroundResource( R.drawable.failed_bg ); if (report.getReportResult() != null && !report.getReportResult().isEmpty()) {
if( report.getReportResult().equalsIgnoreCase("FAILED") ){
status.setBackgroundResource( R.drawable.failed_bg );
}
if( report.getReportResult().equalsIgnoreCase("PASSED") ){
status.setBackgroundResource( R.drawable.passed_bg );
}
if( report.getReportResult().equalsIgnoreCase("ON_HOLD") ){
status.setBackgroundResource( R.drawable.hold_bg );
}
status.setText( report.getReportResult() );
} }
if( report.getReportResult().equalsIgnoreCase("PASSED") ){
status.setBackgroundResource( R.drawable.passed_bg );
}
if( report.getReportResult().equalsIgnoreCase("ON_HOLD") ){
status.setBackgroundResource( R.drawable.hold_bg );
}
status.setText( report.getReportResult() );
} }
} }
} }

View File

@ -8,6 +8,7 @@ import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -65,11 +66,11 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
private InspectionReportService inspectionReportService; private InspectionReportService inspectionReportService;
private RecyclerView vocRecyclerView,itemDimensionsRecyclerView; private RecyclerView vocRecyclerView,itemDimensionsRecyclerView;
private Store store; private Store store;
private Spinner resultSpinner; //private Spinner resultSpinner;
private ApiService apiService; private ApiService apiService;
private EditText generalRemarks, etQualityAuditor, etProdRepresentative, etQcRepresentative; private EditText generalRemarks, etQualityAuditor, etProdRepresentative, etQcRepresentative;
private TextView minorCountTv,majorCountTv,criticalCountTv; private TextView minorCountTv,majorCountTv,criticalCountTv, resultStatus;
@Nullable @Nullable
@Override @Override
@ -268,6 +269,7 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
Handler handler = new Handler(Looper.getMainLooper()); Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> { handler.post(() -> {
Log.e("Report-ToString: ",""+store.getReport().toString());
SharedPreferences sharedPreferences = getContext().getSharedPreferences("login_prefs", Context.MODE_PRIVATE); SharedPreferences sharedPreferences = getContext().getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
long draftReportId = Long.parseLong(sharedPreferences.getString("draftReportId", null)); long draftReportId = Long.parseLong(sharedPreferences.getString("draftReportId", null));
@ -360,12 +362,12 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
etProdRepresentative.setText(store.getReport().getProductionRepresentative()); etProdRepresentative.setText(store.getReport().getProductionRepresentative());
etQcRepresentative.setText(store.getReport().getQcRepresentative()); etQcRepresentative.setText(store.getReport().getQcRepresentative());
ArrayAdapter<String> adapter = new ArrayAdapter<>( getContext(), /*ArrayAdapter<String> adapter = new ArrayAdapter<>( getContext(),
android.R.layout.simple_spinner_item, android.R.layout.simple_spinner_item,
inspectionReportService.getReportResult() ); inspectionReportService.getReportResult() );
resultSpinner.setAdapter( adapter ); resultSpinner.setAdapter( adapter );*/
String defaultSelection = store.getReport().getReportResult(); /*String defaultSelection = store.getReport().getReportResult();
int defaultIndexResultIndex = inspectionReportService.getReportResult().indexOf( defaultSelection ); int defaultIndexResultIndex = inspectionReportService.getReportResult().indexOf( defaultSelection );
resultSpinner.setSelection( defaultIndexResultIndex ); resultSpinner.setSelection( defaultIndexResultIndex );
@ -380,7 +382,7 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
public void onNothingSelected(AdapterView<?> parent) { public void onNothingSelected(AdapterView<?> parent) {
} }
}); });*/
minorCountTv.setText( String.valueOf(0) ); minorCountTv.setText( String.valueOf(0) );
majorCountTv.setText( String.valueOf(0) ) ; majorCountTv.setText( String.valueOf(0) ) ;
@ -413,6 +415,19 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
minorCountTv.setText( String.format("Minor : %d", minor ) ); minorCountTv.setText( String.format("Minor : %d", minor ) );
majorCountTv.setText( String.format("Major : %d", major ) ) ; majorCountTv.setText( String.format("Major : %d", major ) ) ;
criticalCountTv.setText( String.format("Critical : %d", crirical ) ); criticalCountTv.setText( String.format("Critical : %d", crirical ) );
long minorInspection = store.getReport().getItems().get(0).getMinorQualityLevel();
long majorInspection = store.getReport().getItems().get(0).getMinorQualityLevel();
if((long) minor <= minorInspection
&& (long) major <= majorInspection
&& (long) crirical == 0) {
resultStatus.setText("Passed");
store.getReport().setReportResult( "Passed" );
}
else{
resultStatus.setText("Failed");
store.getReport().setReportResult( "Failed" );
}
} }
} }
@ -476,7 +491,8 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
profileImage = view.findViewById( R.id.third_step_profile_image ); profileImage = view.findViewById( R.id.third_step_profile_image );
profileName = view.findViewById( R.id.third_profile_name ); profileName = view.findViewById( R.id.third_profile_name );
vocRecyclerView = view.findViewById( R.id.voc_recyclerview ); vocRecyclerView = view.findViewById( R.id.voc_recyclerview );
resultSpinner = view.findViewById( R.id.result_spinner ); // resultSpinner = view.findViewById( R.id.result_spinner );
resultStatus = view.findViewById( R.id.result_status);
generalRemarks = view.findViewById( R.id.general_remarks ); generalRemarks = view.findViewById( R.id.general_remarks );
itemDimensionsRecyclerView = view.findViewById( R.id.item_dimensions_recyclerview ); itemDimensionsRecyclerView = view.findViewById( R.id.item_dimensions_recyclerview );
minorCountTv = view.findViewById( R.id.minor_count ); minorCountTv = view.findViewById( R.id.minor_count );

File diff suppressed because it is too large Load Diff

View File

@ -331,13 +331,19 @@
android:padding="10dp" android:padding="10dp"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<Spinner
<TextView
android:id="@+id/result_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Result Status"
android:layout_weight="1"/>
<!--<Spinner
android:id="@+id/result_spinner" android:id="@+id/result_spinner"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:prompt="@string/spinner_title" android:prompt="@string/spinner_title" />-->
/>
<TextView <TextView
android:id="@+id/minor_count" android:id="@+id/minor_count"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -3,6 +3,7 @@
<domain-config cleartextTrafficPermitted="true"> <domain-config cleartextTrafficPermitted="true">
<!--<domain includeSubdomains="true">192.168.91.16</domain>--> <!--<domain includeSubdomains="true">192.168.91.16</domain>-->
<domain includeSubdomains="true">192.168.90.27</domain> <domain includeSubdomains="true">192.168.90.27</domain>
<domain includeSubdomains="true">192.168.91.44</domain>
<domain includeSubdomains="true">portal.utopiaindustries.pk</domain> <domain includeSubdomains="true">portal.utopiaindustries.pk</domain>
<domain includeSubdomains="true">utopiaindustries.pk</domain> <domain includeSubdomains="true">utopiaindustries.pk</domain>
</domain-config> </domain-config>