Implementati ean13 in vendita.
Fix su checkDigitEan13.
This commit is contained in:
parent
3c5907a184
commit
61287648e5
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
@ -6,6 +6,7 @@ import it.integry.integrywmsnative.core.REST.RESTBuilder;
|
||||
import it.integry.integrywmsnative.core.REST.model.ServiceRESTResponse;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityDB;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
@ -28,29 +28,36 @@ public class UtilityBarcode {
|
||||
String barcodeEAN13 = null;
|
||||
|
||||
if(barcodeITF14.length() == 14) {
|
||||
barcodeEAN13 = barcodeEAN13.substring(1, barcodeEAN13.length() - 1);
|
||||
barcodeEAN13 += calculateCheckDigitEan13(barcodeEAN13);
|
||||
barcodeEAN13 = barcodeITF14.substring(1, barcodeITF14.length() - 1).trim();
|
||||
barcodeEAN13 += getEAN13CheckDigit(barcodeEAN13);
|
||||
}
|
||||
|
||||
return barcodeEAN13;
|
||||
}
|
||||
|
||||
public static String convertITF14toNeutral(String barcodeITF14) {
|
||||
String barcodeNeutral = null;
|
||||
|
||||
public static int calculateCheckDigitEan13(String barcodeEan13) {
|
||||
String[] barcodeCharArray = barcodeEan13.split("");
|
||||
|
||||
int somma = 0;
|
||||
|
||||
for(int i = 0; i < barcodeCharArray.length; i++){
|
||||
if(i % 2 == 1){
|
||||
somma += Integer.parseInt(barcodeCharArray[i]) * 3;
|
||||
} else {
|
||||
somma += Integer.parseInt(barcodeCharArray[i]);
|
||||
}
|
||||
if(barcodeITF14.length() == 14) {
|
||||
barcodeNeutral = barcodeITF14.substring(1, barcodeITF14.length() - 1);
|
||||
}
|
||||
|
||||
return barcodeNeutral;
|
||||
}
|
||||
|
||||
return 10 - (somma % 10);
|
||||
|
||||
private static String getEAN13CheckDigit(String ean) {
|
||||
|
||||
if (ean.length() != 12) {
|
||||
UtilityLogger.errorMe(new Exception("Please provide an input string of 12 chars. Current lenght: "+ean.length()));
|
||||
return null;
|
||||
}
|
||||
long tot = 0;
|
||||
|
||||
for (int i = 0; i < 12; i++) {
|
||||
tot = tot + (Long.parseLong(String.valueOf(ean.charAt(i))) * (i % 2 == 0 ? 1 : 3));
|
||||
}
|
||||
return tot % 10 == 0 ? "0" : "" +(10-(tot % 10));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -277,6 +277,7 @@ public class AccettazioneOnOrdineAccettazioneInevasoViewModel implements IOnColl
|
||||
|
||||
private void loadArticolo(String barcodeProd, Ean128Model ean128Model, ProgressDialog progressDialog) {
|
||||
if(barcodeProd.length() == 14) {
|
||||
// barcodeProd = UtilityBarcode.convertITF14toNeutral(barcodeProd);
|
||||
barcodeProd = UtilityBarcode.convertITF14toEAN13(barcodeProd);
|
||||
}
|
||||
|
||||
|
||||
@ -207,22 +207,29 @@ public class LoginViewModel {
|
||||
}
|
||||
|
||||
private void showProfileDBSelectionDialog(final String host, final int port, final List<String> availableProfiles){
|
||||
// setup the alert builder
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
||||
builder.setTitle(R.string.action_choose_profile_db);
|
||||
|
||||
// add a list
|
||||
String[] profiles = new String[availableProfiles.size()];
|
||||
profiles = availableProfiles.toArray(profiles);
|
||||
builder.setItems(profiles, (dialog, which) -> {
|
||||
SettingsManager.i().userSession.profileDB = availableProfiles.get(which);
|
||||
if(availableProfiles != null && availableProfiles.size() == 1 ) {
|
||||
SettingsManager.i().userSession.profileDB = availableProfiles.get(0);
|
||||
|
||||
loadDepo(host, port, this::onLoginCompleted);
|
||||
});
|
||||
} else {
|
||||
|
||||
// create and show the alert dialog
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
// setup the alert builder
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
||||
builder.setTitle(R.string.action_choose_profile_db);
|
||||
|
||||
// add a list
|
||||
String[] profiles = new String[availableProfiles.size()];
|
||||
profiles = availableProfiles.toArray(profiles);
|
||||
builder.setItems(profiles, (dialog, which) -> {
|
||||
SettingsManager.i().userSession.profileDB = availableProfiles.get(which);
|
||||
|
||||
loadDepo(host, port, this::onLoginCompleted);
|
||||
});
|
||||
|
||||
// create and show the alert dialog
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
public void onLoginCompleted() {
|
||||
|
||||
@ -279,10 +279,14 @@ public class VenditaOrdineInevasoViewModel implements IOnColloClosedCallback, IO
|
||||
this.executeEtichettaAnonimaNotOpenedLU(data, progressDialog);
|
||||
} else if(data.getType() == BarcodeType.EAN128) {
|
||||
|
||||
//Creo una nuova ul e cerco tramite etichetta ean 128 (che può indicarmi un articolo o una UL)
|
||||
this.createNewUL(null, null, progressDialog, false, false, () -> {
|
||||
this.executeEtichettaEan128(data, progressDialog);
|
||||
});
|
||||
|
||||
} else {
|
||||
this.createNewUL(null, null, progressDialog, false, false, () -> {
|
||||
this.loadArticolo(data.getStringValue(), null, progressDialog);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if(UtilityBarcode.isEtichettaAnonima(data)){
|
||||
@ -290,8 +294,10 @@ public class VenditaOrdineInevasoViewModel implements IOnColloClosedCallback, IO
|
||||
this.executeEtichettaLU(data.getStringValue(), progressDialog);
|
||||
} else if(data.getType() == BarcodeType.EAN128) {
|
||||
|
||||
//Cerco tramite etichetta ean 128 (che può indicarmi un articolo o una UL)
|
||||
this.executeEtichettaEan128(data, progressDialog);
|
||||
|
||||
} else {
|
||||
this.loadArticolo(data.getStringValue(), null, progressDialog);
|
||||
}
|
||||
}
|
||||
|
||||
@ -384,6 +390,7 @@ public class VenditaOrdineInevasoViewModel implements IOnColloClosedCallback, IO
|
||||
|
||||
private void loadArticolo(String barcodeProd, PickingObjectDTO.PickData pickData, ProgressDialog progressDialog) {
|
||||
if(barcodeProd.length() == 14) {
|
||||
// barcodeProd = UtilityBarcode.convertITF14toNeutral(barcodeProd);
|
||||
barcodeProd = UtilityBarcode.convertITF14toEAN13(barcodeProd);
|
||||
}
|
||||
|
||||
|
||||
@ -74,9 +74,11 @@ public class PointMobileBarcodeReader implements BarcodeReaderInterface {
|
||||
|
||||
if (mOnScanSuccessfull != null) {
|
||||
|
||||
try {
|
||||
//try {
|
||||
if(mDecodeResult.symName.equalsIgnoreCase("READ_FAIL")){
|
||||
throw new Exception("Barcode non riconosciuto");
|
||||
//throw new Exception("Barcode non riconosciuto");
|
||||
if(mOnScanFailed != null) mOnScanFailed.run(new Exception("Barcode non riconosciuto"));
|
||||
return;
|
||||
}
|
||||
|
||||
BarcodeScanDTO barcodeScanDTO = new BarcodeScanDTO()
|
||||
@ -88,11 +90,11 @@ public class PointMobileBarcodeReader implements BarcodeReaderInterface {
|
||||
|
||||
mOnScanSuccessfull.run(barcodeScanDTO);
|
||||
|
||||
} catch (Exception ex) {
|
||||
Log.e(TAG, ex.getMessage());
|
||||
//} catch (Exception ex) {
|
||||
// Log.e(TAG, ex.getMessage());
|
||||
|
||||
if(mOnScanFailed != null) mOnScanFailed.run(ex);
|
||||
}
|
||||
// if(mOnScanFailed != null) mOnScanFailed.run(ex);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user