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.REST.model.ServiceRESTResponse;
|
||||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||||
import it.integry.integrywmsnative.core.model.MtbAart;
|
import it.integry.integrywmsnative.core.model.MtbAart;
|
||||||
|
import it.integry.integrywmsnative.core.utility.UtilityDB;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
|
|||||||
@ -28,29 +28,36 @@ public class UtilityBarcode {
|
|||||||
String barcodeEAN13 = null;
|
String barcodeEAN13 = null;
|
||||||
|
|
||||||
if(barcodeITF14.length() == 14) {
|
if(barcodeITF14.length() == 14) {
|
||||||
barcodeEAN13 = barcodeEAN13.substring(1, barcodeEAN13.length() - 1);
|
barcodeEAN13 = barcodeITF14.substring(1, barcodeITF14.length() - 1).trim();
|
||||||
barcodeEAN13 += calculateCheckDigitEan13(barcodeEAN13);
|
barcodeEAN13 += getEAN13CheckDigit(barcodeEAN13);
|
||||||
}
|
}
|
||||||
|
|
||||||
return barcodeEAN13;
|
return barcodeEAN13;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String convertITF14toNeutral(String barcodeITF14) {
|
||||||
|
String barcodeNeutral = null;
|
||||||
|
|
||||||
public static int calculateCheckDigitEan13(String barcodeEan13) {
|
if(barcodeITF14.length() == 14) {
|
||||||
String[] barcodeCharArray = barcodeEan13.split("");
|
barcodeNeutral = barcodeITF14.substring(1, barcodeITF14.length() - 1);
|
||||||
|
|
||||||
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]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
private void loadArticolo(String barcodeProd, Ean128Model ean128Model, ProgressDialog progressDialog) {
|
||||||
if(barcodeProd.length() == 14) {
|
if(barcodeProd.length() == 14) {
|
||||||
|
// barcodeProd = UtilityBarcode.convertITF14toNeutral(barcodeProd);
|
||||||
barcodeProd = UtilityBarcode.convertITF14toEAN13(barcodeProd);
|
barcodeProd = UtilityBarcode.convertITF14toEAN13(barcodeProd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -207,6 +207,12 @@ public class LoginViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showProfileDBSelectionDialog(final String host, final int port, final List<String> availableProfiles){
|
private void showProfileDBSelectionDialog(final String host, final int port, final List<String> availableProfiles){
|
||||||
|
if(availableProfiles != null && availableProfiles.size() == 1 ) {
|
||||||
|
SettingsManager.i().userSession.profileDB = availableProfiles.get(0);
|
||||||
|
|
||||||
|
loadDepo(host, port, this::onLoginCompleted);
|
||||||
|
} else {
|
||||||
|
|
||||||
// setup the alert builder
|
// setup the alert builder
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
||||||
builder.setTitle(R.string.action_choose_profile_db);
|
builder.setTitle(R.string.action_choose_profile_db);
|
||||||
@ -224,6 +230,7 @@ public class LoginViewModel {
|
|||||||
AlertDialog dialog = builder.create();
|
AlertDialog dialog = builder.create();
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onLoginCompleted() {
|
public void onLoginCompleted() {
|
||||||
loginButtonEnabled.set(true);
|
loginButtonEnabled.set(true);
|
||||||
|
|||||||
@ -279,10 +279,14 @@ public class VenditaOrdineInevasoViewModel implements IOnColloClosedCallback, IO
|
|||||||
this.executeEtichettaAnonimaNotOpenedLU(data, progressDialog);
|
this.executeEtichettaAnonimaNotOpenedLU(data, progressDialog);
|
||||||
} else if(data.getType() == BarcodeType.EAN128) {
|
} 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.createNewUL(null, null, progressDialog, false, false, () -> {
|
||||||
this.executeEtichettaEan128(data, progressDialog);
|
this.executeEtichettaEan128(data, progressDialog);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.createNewUL(null, null, progressDialog, false, false, () -> {
|
||||||
|
this.loadArticolo(data.getStringValue(), null, progressDialog);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(UtilityBarcode.isEtichettaAnonima(data)){
|
if(UtilityBarcode.isEtichettaAnonima(data)){
|
||||||
@ -290,8 +294,10 @@ public class VenditaOrdineInevasoViewModel implements IOnColloClosedCallback, IO
|
|||||||
this.executeEtichettaLU(data.getStringValue(), progressDialog);
|
this.executeEtichettaLU(data.getStringValue(), progressDialog);
|
||||||
} else if(data.getType() == BarcodeType.EAN128) {
|
} else if(data.getType() == BarcodeType.EAN128) {
|
||||||
|
|
||||||
|
//Cerco tramite etichetta ean 128 (che può indicarmi un articolo o una UL)
|
||||||
this.executeEtichettaEan128(data, progressDialog);
|
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) {
|
private void loadArticolo(String barcodeProd, PickingObjectDTO.PickData pickData, ProgressDialog progressDialog) {
|
||||||
if(barcodeProd.length() == 14) {
|
if(barcodeProd.length() == 14) {
|
||||||
|
// barcodeProd = UtilityBarcode.convertITF14toNeutral(barcodeProd);
|
||||||
barcodeProd = UtilityBarcode.convertITF14toEAN13(barcodeProd);
|
barcodeProd = UtilityBarcode.convertITF14toEAN13(barcodeProd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -74,9 +74,11 @@ public class PointMobileBarcodeReader implements BarcodeReaderInterface {
|
|||||||
|
|
||||||
if (mOnScanSuccessfull != null) {
|
if (mOnScanSuccessfull != null) {
|
||||||
|
|
||||||
try {
|
//try {
|
||||||
if(mDecodeResult.symName.equalsIgnoreCase("READ_FAIL")){
|
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()
|
BarcodeScanDTO barcodeScanDTO = new BarcodeScanDTO()
|
||||||
@ -88,11 +90,11 @@ public class PointMobileBarcodeReader implements BarcodeReaderInterface {
|
|||||||
|
|
||||||
mOnScanSuccessfull.run(barcodeScanDTO);
|
mOnScanSuccessfull.run(barcodeScanDTO);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
//} catch (Exception ex) {
|
||||||
Log.e(TAG, ex.getMessage());
|
// 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