Implementata logica della posizione di default sull'articolo in caso di addExtraItem

This commit is contained in:
Giuseppe Scorrano 2022-03-07 12:43:11 +01:00
parent e0eabbcbda
commit da70d7c064
18 changed files with 109 additions and 245 deletions

View File

@ -15,6 +15,7 @@
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="true" />
<option name="SKIP_NOOP_APK_INSTALLATIONS" value="true" />
<option name="FORCE_STOP_RUNNING_APP" value="true" />
<option name="INSPECTION_WITHOUT_ACTIVITY_RESTART" value="false" />
<option name="TARGET_SELECTION_MODE" value="SHOW_DIALOG" />
<option name="SELECTED_CLOUD_MATRIX_CONFIGURATION_ID" value="-1" />
<option name="SELECTED_CLOUD_MATRIX_PROJECT_ID" value="" />
@ -45,7 +46,7 @@
<option name="ADVANCED_PROFILING_ENABLED" value="false" />
<option name="STARTUP_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_CONFIGURATION_NAME" value="Sample Java Methods" />
<option name="STARTUP_CPU_PROFILING_CONFIGURATION_NAME" value="Callstack Sample" />
<option name="STARTUP_NATIVE_MEMORY_PROFILING_ENABLED" value="false" />
<option name="NATIVE_MEMORY_SAMPLE_RATE_BYTES" value="2048" />
</Profilers>

View File

@ -15,6 +15,7 @@
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="true" />
<option name="SKIP_NOOP_APK_INSTALLATIONS" value="true" />
<option name="FORCE_STOP_RUNNING_APP" value="true" />
<option name="INSPECTION_WITHOUT_ACTIVITY_RESTART" value="false" />
<option name="TARGET_SELECTION_MODE" value="SHOW_DIALOG" />
<option name="SELECTED_CLOUD_MATRIX_CONFIGURATION_ID" value="-1" />
<option name="SELECTED_CLOUD_MATRIX_PROJECT_ID" value="" />
@ -45,7 +46,7 @@
<option name="ADVANCED_PROFILING_ENABLED" value="false" />
<option name="STARTUP_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_CONFIGURATION_NAME" value="Sample Java Methods" />
<option name="STARTUP_CPU_PROFILING_CONFIGURATION_NAME" value="Callstack Sample" />
<option name="STARTUP_NATIVE_MEMORY_PROFILING_ENABLED" value="false" />
<option name="NATIVE_MEMORY_SAMPLE_RATE_BYTES" value="2048" />
</Profilers>

View File

@ -85,6 +85,7 @@ android {
dynamicFeatures = [":dynamic__base", ":dynamic_vgalimenti"]
}
dependencies {
@ -138,7 +139,6 @@ dependencies {
implementation 'com.github.cachapa:ExpandableLayout:2.9.2'
implementation 'com.github.frankiesardo:linearlistview:1.0.1@aar'
implementation 'com.github.fede87:StatusBarAlert:1.0.1'
testImplementation 'junit:junit:4.13.2'
implementation 'com.github.zhukic:sectioned-recyclerview:1.2.3'
implementation 'com.github.pedromassango:doubleClick:3.0'
@ -157,11 +157,14 @@ dependencies {
implementation project(':barcode_base_android_library')
implementation project(':honeywellscannerlibrary')
implementation project(':keyobardemulatorscannerlibrary')
androidTestImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.1'
androidTestImplementation 'org.testng:testng:7.4.0'
implementation 'com.github.RaviKoradiya:LiveAdapter:1.3.4'
// Required -- JUnit 4 framework
// testImplementation "org.junit.jupiter:junit-jupiter-api:5.8.1"
// androidTestImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
// androidTestImplementation 'org.testng:testng:7.4.0'
}
repositories {

View File

@ -1,8 +0,0 @@
package it.integry.integrywmsnative.gest.spedizione;
class SpedizioneViewModelTest {
@org.junit.jupiter.api.Test
void createNewLU() {
}
}

View File

@ -87,7 +87,7 @@ public class ArticoloOrdine {
return articoloOrdineId;
}
public void setArticoloOrdineId(int articoloOrdineId) {
public void setArticoloOrdineId(Integer articoloOrdineId) {
this.articoloOrdineId = articoloOrdineId;
}

View File

@ -53,7 +53,7 @@ public class PosizioniRESTConsumer extends _BaseRESTConsumer{
String codMdep = null;
PosizioniRESTConsumerService posizioniRESTConsumerService = RESTBuilder.getService(PosizioniRESTConsumerService.class);
posizioniRESTConsumerService.getAvailablePosizioni(codMdep).enqueue(new Callback<ServiceRESTResponse<List<MtbDepoPosizione>>>() {
posizioniRESTConsumerService.getAvailablePosizioni(codMdep).enqueue(new Callback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<List<MtbDepoPosizione>>> call, Response<ServiceRESTResponse<List<MtbDepoPosizione>>> response) {
analyzeAnswer(response, "getAvailablePosizioni", (m) -> {

View File

@ -125,6 +125,7 @@ public class SpedizioneListAdapter extends SectionedRecyclerViewAdapter<Spedizio
holder.mBinding.deactivatedOverBg.setVisibility(!pickingObjectDTO.isActive() ? View.VISIBLE : View.GONE);
holder.mBinding.getRoot().setAlpha(!pickingObjectDTO.isActive() ? 0.8f : 1);
holder.mBinding.badge1.setBackground(ResourcesCompat.getDrawable(mContext.getResources(), !pickingObjectDTO.isActive() ? R.drawable.badge_round_corner : R.drawable.badge1_round_corner, null));
holder.mBinding.badge1.setTextColor(ResourcesCompat.getColor(mContext.getResources(), !pickingObjectDTO.isActive() ? R.color.gray_600 : R.color.white, null));
holder.mBinding.qtaEvasa.setTextColor(ResourcesCompat.getColor(mContext.getResources(), !pickingObjectDTO.isActive() ? R.color.gray_600 : R.color.green_700, null));
holder.mBinding.descrizione.setText(pickingObjectDTO.getDescrizione());

View File

@ -5,13 +5,17 @@ import dagger.Provides;
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PosizioniRESTConsumer;
@Module(subcomponents = DialogScanArtComponent.class)
public class DialogScanArtModule {
@Provides
DialogScanArtViewModel providesDialogScanArtViewModel(BarcodeRESTConsumer barcodeRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, ArticoloRESTConsumer articoloRESTConsumer) {
return new DialogScanArtViewModel(barcodeRESTConsumer, colliMagazzinoRESTConsumer, articoloRESTConsumer);
DialogScanArtViewModel providesDialogScanArtViewModel(BarcodeRESTConsumer barcodeRESTConsumer,
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
ArticoloRESTConsumer articoloRESTConsumer,
PosizioniRESTConsumer posizioniRESTConsumer) {
return new DialogScanArtViewModel(barcodeRESTConsumer, colliMagazzinoRESTConsumer, articoloRESTConsumer, posizioniRESTConsumer);
}
}

View File

@ -12,6 +12,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import com.annimon.stream.Stream;
import org.jetbrains.annotations.NotNull;
import javax.inject.Inject;
@ -84,7 +86,6 @@ public class DialogScanArtView extends BaseDialogFragment implements DialogScanA
}
@Override
public void onDismiss(@NonNull DialogInterface dialog) {
BarcodeManager.removeCallback(mBarcodeScannerIstanceID);
@ -107,14 +108,28 @@ public class DialogScanArtView extends BaseDialogFragment implements DialogScanA
this.openProgress();
this.mViewModel.processBarcodeDTO(data, (status, mtbAart, ean128Model, mtbColrList) -> {
if(mtbColrList != null && mtbColrList.size() > 0) {
DialogChooseArtFromListaMtbColrView.make(getActivity(), mtbColrList, mtbColrChose -> {
var filteredMtbColrList = mtbColrList;
if (mtbAart != null) {
filteredMtbColrList = Stream.of(filteredMtbColrList)
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbAart.getCodMart()))
.toList();
}
if (filteredMtbColrList != null && filteredMtbColrList.size() > 1) {
DialogChooseArtFromListaMtbColrView.make(getActivity(), filteredMtbColrList, mtbColrChose -> {
mOnItemChoosed.run(status, mtbAart, ean128Model, mtbColrChose);
}).show();
} else if (filteredMtbColrList != null && filteredMtbColrList.size() == 1) {
mOnItemChoosed.run(status, mtbAart, ean128Model, filteredMtbColrList.get(0));
} else {
mOnItemChoosed.run(status, mtbAart, ean128Model, null);
}
BarcodeManager.enable();
this.closeProgress();

View File

@ -7,16 +7,21 @@ import java.util.List;
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
import it.integry.integrywmsnative.core.exception.InvalidLUException;
import it.integry.integrywmsnative.core.exception.NoArtsFoundException;
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException;
import it.integry.integrywmsnative.core.exception.TooManyLUFoundInMonoLUPositionException;
import it.integry.integrywmsnative.core.expansion.RunnableArgssss;
import it.integry.integrywmsnative.core.model.MtbAart;
import it.integry.integrywmsnative.core.model.MtbColr;
import it.integry.integrywmsnative.core.model.MtbDepoPosizione;
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PosizioniRESTConsumer;
import it.integry.integrywmsnative.core.rest.model.Ean128Model;
import it.integry.integrywmsnative.core.rest.model.Ean13PesoModel;
import it.integry.integrywmsnative.core.utility.UtilityBarcode;
import it.integry.integrywmsnative.core.utility.UtilityPosizione;
import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.view.dialogs.DialogConsts;
@ -25,15 +30,20 @@ public class DialogScanArtViewModel {
private final BarcodeRESTConsumer mBarcodeRESTConsumer;
private final ColliMagazzinoRESTConsumer mColliMagazzinoRESTConsumer;
private final ArticoloRESTConsumer mArticoloRESTConsumer;
private final PosizioniRESTConsumer mPosizioniRESTConsumer;
private boolean mForceOnlyUL;
private Listener mListener;
public DialogScanArtViewModel(BarcodeRESTConsumer barcodeRESTConsumer, ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer, ArticoloRESTConsumer articoloRESTConsumer) {
public DialogScanArtViewModel(BarcodeRESTConsumer barcodeRESTConsumer,
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
ArticoloRESTConsumer articoloRESTConsumer,
PosizioniRESTConsumer posizioniRESTConsumer) {
this.mBarcodeRESTConsumer = barcodeRESTConsumer;
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
this.mArticoloRESTConsumer = articoloRESTConsumer;
this.mPosizioniRESTConsumer = posizioniRESTConsumer;
}
public DialogScanArtViewModel setForceOnlyUL(boolean forceOnlyUL) {
@ -50,15 +60,19 @@ public class DialogScanArtViewModel {
//Cerco l'UL presente all'interno della posizione
// this.executeEtichettaPosizione(barcodeScanDTO.getStringValue(), onComplete);
} else if(UtilityBarcode.isEtichetta128(barcodeScanDTO)) {
} else if (UtilityBarcode.isEtichetta128(barcodeScanDTO)) {
this.executeEtichettaEan128(barcodeScanDTO, onComplete);
} else if(UtilityBarcode.isEanPeso(barcodeScanDTO) && !mForceOnlyUL){
} else if (UtilityBarcode.isEanPeso(barcodeScanDTO) && !mForceOnlyUL) {
this.executeEtichettaEanPeso(barcodeScanDTO, onComplete);
} else if (!mForceOnlyUL){
this.loadArticolo(barcodeScanDTO.getStringValue(), null, onComplete);
} else {
this.sendError(new Exception("Barcode non valido"));
this.loadArticolo(barcodeScanDTO.getStringValue(), null, onComplete);
}
// else {
// this.sendError(new Exception("Barcode non valido"));
// }
}
@ -67,15 +81,15 @@ public class DialogScanArtViewModel {
String barcodeProd = null;
if(ean128Model.Sscc != null) barcodeProd = ean128Model.Sscc;
if(ean128Model.Gtin != null) barcodeProd = ean128Model.Gtin;
if(ean128Model.Content != null) barcodeProd = ean128Model.Content;
if (ean128Model.Sscc != null) barcodeProd = ean128Model.Sscc;
if (ean128Model.Gtin != null) barcodeProd = ean128Model.Gtin;
if (ean128Model.Content != null) barcodeProd = ean128Model.Content;
if(!UtilityString.isNullOrEmpty(barcodeProd)) {
if (!UtilityString.isNullOrEmpty(barcodeProd)) {
if (!UtilityString.isNullOrEmpty(ean128Model.Sscc)) {
this.executeEtichettaLU(ean128Model.Sscc, onComplete);
} else if(!mForceOnlyUL) {
} else if (!mForceOnlyUL) {
if (barcodeProd.startsWith("0") || barcodeProd.startsWith("9")) {
barcodeProd = barcodeProd.substring(1);
}
@ -117,17 +131,43 @@ public class DialogScanArtViewModel {
}, this::sendError);
}
private void executePosizione(MtbDepoPosizione posizione, MtbAart articolo, RunnableArgssss<DialogConsts.Results, MtbAart, Ean128Model, List<MtbColr>> onComplete) {
this.mPosizioniRESTConsumer.getBancaliInPosizione(posizione, mtbColtList -> {
if (mtbColtList == null || mtbColtList.size() == 0) {
this.sendError(new NoLUFoundException());
} else if (mtbColtList.size() == 1) {
this.mColliMagazzinoRESTConsumer.getByTestata(mtbColtList.get(0), true, false, mtbColt -> {
onComplete.run(DialogConsts.Results.YES, articolo, null, mtbColt.getMtbColr());
}, this::sendError);
} else {
this.sendError(new TooManyLUFoundInMonoLUPositionException());
}
}, this::sendError);
}
private void loadArticolo(@NotNull String barcodeProd, Ean128Model ean128Model, RunnableArgssss<DialogConsts.Results, MtbAart, Ean128Model, List<MtbColr>> onComplete) {
if(barcodeProd.length() == 14) {
// barcodeProd = UtilityBarcode.convertITF14toNeutral(barcodeProd);
if (barcodeProd.length() == 14) {
barcodeProd = UtilityBarcode.convertITF14toEAN13(barcodeProd);
}
String finalBarcodeProd = barcodeProd;
this.mArticoloRESTConsumer.getByBarcodeProd(barcodeProd, mtbAartList -> {
if(mtbAartList != null && mtbAartList.size() > 0) {
onComplete.run(DialogConsts.Results.YES, mtbAartList.get(0), ean128Model, null);
if (mtbAartList != null && mtbAartList.size() > 0) {
MtbAart firstArt = mtbAartList.get(0);
MtbDepoPosizione firstArtPosition = UtilityPosizione.getFromCache(firstArt.getPosizione());
if (firstArtPosition != null && firstArtPosition.isFlagMonoCollo() && mForceOnlyUL) {
this.executePosizione(firstArtPosition, firstArt, onComplete);
} else if (!mForceOnlyUL) {
onComplete.run(DialogConsts.Results.YES, mtbAartList.get(0), ean128Model, null);
} else {
this.sendError(new NoResultFromBarcodeException(finalBarcodeProd));
}
} else {
this.sendError(new NoResultFromBarcodeException(finalBarcodeProd));
}
@ -135,8 +175,6 @@ public class DialogScanArtViewModel {
}
private void sendError(Exception ex) {
if (this.mListener != null) mListener.onError(ex);
}

View File

@ -4,9 +4,10 @@
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.cardview.widget.CardView
android:orientation="vertical" android:layout_width="match_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical"
app:cardCornerRadius="12dp"
app:cardElevation="0dp">
@ -21,17 +22,17 @@
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:paddingTop="24dp"
android:paddingEnd="24dp"
android:paddingBottom="12dp">
<TextView
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/title_text"
style="@style/TextViewMaterial.Dialog.HeadlineText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/TextViewMaterial.Dialog.HeadlineText"
android:text="@string/extra_item"
android:gravity="center_horizontal"/>
android:gravity="center_horizontal"
android:text="@string/extra_item" />
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="wrap_content"
@ -45,32 +46,31 @@
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/AppTheme.NewMaterial.Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
android:layout_marginEnd="12dp"
android:layout_gravity="center_vertical"
android:gravity="center_horizontal"
style="@style/AppTheme.NewMaterial.Text"
android:text="@string/scan_item"/>
android:text="@string/scan_item"
android:textSize="16sp" />
</androidx.appcompat.widget.LinearLayoutCompat>
<com.google.android.material.button.MaterialButton
android:id="@+id/button_no"
style="@style/Button.DangerOutline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
style="@style/Button.DangerOutline"
app:strokeColor="@color/red_400"
app:layout_constraintTop_toTopOf="parent"
android:layout_gravity="center_horizontal"
android:text="@string/abort"/>
android:layout_marginTop="16dp"
android:text="@string/abort"
app:layout_constraintTop_toTopOf="parent"
app:strokeColor="@color/red_400" />
</androidx.appcompat.widget.LinearLayoutCompat>
@ -78,5 +78,4 @@
</androidx.cardview.widget.CardView>
</layout>

View File

@ -1 +0,0 @@
/build

View File

@ -1,5 +0,0 @@
apply plugin: 'java-library'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
}

View File

@ -1,9 +0,0 @@
package it.integry.barcode_base_android_library.exception;
public class BarcodeAdapterNotFoundException extends Exception {
public BarcodeAdapterNotFoundException(String adapterName) {
super("L'adapter " + adapterName + " non è stato rilevato sul dispositivo corrente");
}
}

View File

@ -1,7 +0,0 @@
package it.integry.barcode_base_android_library.extension;
public interface RunnableArgs<T> {
void run(T data);
}

View File

@ -1,22 +0,0 @@
package it.integry.barcode_base_android_library.interfaces;
import it.integry.barcode_base_android_library.extension.RunnableArgs;
import it.integry.barcode_base_android_library.exception.BarcodeAdapterNotFoundException;
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
public interface BarcodeReaderInterface {
boolean isRightAdapter();
void init(Runnable onDeviceReady) throws BarcodeAdapterNotFoundException;
void deinit();
void register(RunnableArgs<BarcodeScanDTO> onScanSuccessfull, RunnableArgs<Exception> onScanFailed);
String getAdapterName();
//void onKeyEvent(KeyEvent keyEvent);
}

View File

@ -1,55 +0,0 @@
package it.integry.barcode_base_android_library.model;
public class BarcodeScanDTO {
private BarcodeType type;
private String stringValue;
private byte[] byteValue;
private String name;
private int decodingTime;
public BarcodeType getType() {
return type;
}
public BarcodeScanDTO setType(BarcodeType type) {
this.type = type;
return this;
}
public String getStringValue() {
return stringValue;
}
public BarcodeScanDTO setStringValue(String stringValue) {
this.stringValue = stringValue;
return this;
}
public byte[] getByteValue() {
return byteValue;
}
public BarcodeScanDTO setByteValue(byte[] byteValue) {
this.byteValue = byteValue;
return this;
}
public String getName() {
return name;
}
public BarcodeScanDTO setName(String name) {
this.name = name;
return this;
}
public int getDecodingTime() {
return decodingTime;
}
public BarcodeScanDTO setDecodingTime(int decodingTime) {
this.decodingTime = decodingTime;
return this;
}
}

View File

@ -1,91 +0,0 @@
package it.integry.barcode_base_android_library.model;
public enum BarcodeType {
NIL(0),
AIRLINE_2OF5_13_DIGIT(1),
AIRLINE_2OF5_15_DIGIT(2),
AZTEC(3),
AUSTRALIAN_POSTAL(4),
BOOKLAND_EAN(5),
BPO(6),
CANPOST(7),
CHINAPOST(8),
CHINESE_2OF5(9),
CODABAR(10),
CODABLOCK(11),
CODE11(12),
CODE128(13),
CODE16K(14),
CODE32(15),
CODE39(16),
CODE49(17),
CODE93(18),
COMPOSITE(19),
COUPON_CODE(20),
DATAMATRIX(21),
DISCRETE_2OF5(22),
DUTCH_POSTAL(23),
EAN128(24),
EAN13(25),
EAN8(26),
GS1_DATABAR_14(27),
GS1_DATABAR_EXPANDED(28),
GS1_DATABAR_LIMITED(29),
HONGKONG_2OF5(30),
IATA_2OF5(31),
IDTAG(32),
INTERLEAVED_2OF5(33),
ISBT128(34),
JAPANESE_POSTAL(35),
KOREAN_POSTAL(36),
MATRIX_2OF5(37),
MAXICODE(38),
MESA(39),
MICRO_PDF417(40),
MICRO_QR(41),
MSI(42),
NEC_2OF5(43),
OCR(44),
PDF417(45),
PLESSEY(46),
POSICODE(47),
POST_US4(48),
QR(49),
STRAIGHT_2OF5(50),
STANDARD_2OF5(51),
TELEPEN(52),
TLCODE39(53),
TRIOPTIC(54),
UK_POSTAL(55),
UPCA(56),
UPCE(57),
UPCE1(58),
US_PLANET(59),
US_POSTNET(60),
USPS_4CB(61),
RSS(62),
LABEL(63),
HANXIN(64),
GRIDMATRIX(65),
INFO_MAIL(66),
INTELLIGENT_MAIL(67),
SWEDENPOST(68),
LAST(69);
private Integer text;
BarcodeType(Integer text) {
this.text = text;
}
public Integer getValue() {
return this.text;
}
public static BarcodeType fromInt(Integer text) {
for (BarcodeType b : BarcodeType.values()) {
if (b.text.equals(text)) return b;
}
return null;
}
}