Implementato salvataggio file per recover collo V
This commit is contained in:
parent
c7b4e17048
commit
591dda7b2e
@ -22,6 +22,14 @@
|
||||
"certificate_hash": "864b69dcc40196befa65638a868cec1c61245fa6"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "963231271247-59qdc1vobbnjfp135ce4hv12c53s9hse.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "it.integry.integrywmsnative",
|
||||
"certificate_hash": "3b6d97a981f446f5011049d781aeb9960f9352af"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "963231271247-6jof105pci1g0g7m2e7kjbtrtk2443g4.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
|
||||
@ -5,9 +5,6 @@ public class CommonConst {
|
||||
public static class Login {
|
||||
|
||||
public static class Azienda {
|
||||
// public static String host = "192.168.2.13";
|
||||
// public static int port = 8080;
|
||||
|
||||
public static String host = "www2.studioml.it";
|
||||
public static int port = 80;
|
||||
}
|
||||
@ -20,6 +17,9 @@ public class CommonConst {
|
||||
public static String DEFAULT_ANONYMOUS_UL_SERIE = "UL";
|
||||
}
|
||||
|
||||
public static class Files {
|
||||
public static String RECOVER_COLLO_FILE = "recover_ul.json";
|
||||
}
|
||||
|
||||
public static class Mail {
|
||||
|
||||
|
||||
@ -10,6 +10,8 @@ import io.fabric.sdk.android.Fabric;
|
||||
import it.integry.integrywmsnative.BuildConfig;
|
||||
import it.integry.integrywmsnative.core.REST.watcher.ServerStatusChecker;
|
||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
||||
import it.integry.integrywmsnative.core.data_recover.ColliDataRecover;
|
||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.settings.Stash;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityResources;
|
||||
@ -30,7 +32,7 @@ public class AppContext {
|
||||
public void init() {
|
||||
this.initSettings();
|
||||
|
||||
//this.initCrashlytics();
|
||||
this.initCrashlytics();
|
||||
|
||||
this.initServerStatusChecker();
|
||||
|
||||
@ -39,6 +41,8 @@ public class AppContext {
|
||||
this.initUtilities();
|
||||
|
||||
this.initLogger();
|
||||
|
||||
this.initRecoverColli();
|
||||
}
|
||||
|
||||
|
||||
@ -78,5 +82,14 @@ public class AppContext {
|
||||
Logger.addLogAdapter(new AndroidLogAdapter());
|
||||
}
|
||||
|
||||
private void initRecoverColli() {
|
||||
ColliDataRecover.init(mContext);
|
||||
|
||||
if(ColliDataRecover.thereIsAnExistantSession()){
|
||||
MtbColt recoveredMtbColt = ColliDataRecover.getFirstSession();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,125 @@
|
||||
package it.integry.integrywmsnative.core.data_recover;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.integrywmsnative.core.CommonConst;
|
||||
import it.integry.integrywmsnative.core.model.MtbColt;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
|
||||
|
||||
public class ColliDataRecover {
|
||||
|
||||
private static class RecoverDTO {
|
||||
private int numCollo;
|
||||
private String serCollo;
|
||||
private String dataCollo;
|
||||
private String gestioneCollo;
|
||||
|
||||
public int getNumCollo() {
|
||||
return numCollo;
|
||||
}
|
||||
|
||||
public RecoverDTO setNumCollo(int numCollo) {
|
||||
this.numCollo = numCollo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSerCollo() {
|
||||
return serCollo;
|
||||
}
|
||||
|
||||
public RecoverDTO setSerCollo(String serCollo) {
|
||||
this.serCollo = serCollo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDataCollo() {
|
||||
return dataCollo;
|
||||
}
|
||||
|
||||
public RecoverDTO setDataCollo(String dataCollo) {
|
||||
this.dataCollo = dataCollo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getGestioneCollo() {
|
||||
return gestioneCollo;
|
||||
}
|
||||
|
||||
public RecoverDTO setGestioneCollo(String gestioneCollo) {
|
||||
this.gestioneCollo = gestioneCollo;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private static Context mContext;
|
||||
|
||||
private static List<RecoverDTO> mtbColtsSessions = new ArrayList<>();
|
||||
|
||||
public static void init(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public static boolean thereIsAnExistantSession() {
|
||||
return mtbColtsSessions.size() > 0;
|
||||
}
|
||||
|
||||
public static MtbColt getFirstSession() {
|
||||
|
||||
if(thereIsAnExistantSession()){
|
||||
RecoverDTO dto = mtbColtsSessions.get(0);
|
||||
mtbColtsSessions.remove(dto);
|
||||
|
||||
return new MtbColt()
|
||||
.setNumCollo(dto.getNumCollo())
|
||||
.setSerCollo(dto.getSerCollo())
|
||||
.setGestione(dto.getGestioneCollo())
|
||||
.setDataCollo(dto.getDataCollo());
|
||||
|
||||
|
||||
} else return null;
|
||||
|
||||
}
|
||||
|
||||
public static int startNewSession(MtbColt mtbColtSession) {
|
||||
|
||||
RecoverDTO recoverDTO = new RecoverDTO()
|
||||
.setDataCollo(mtbColtSession.getDataColloS())
|
||||
.setNumCollo(mtbColtSession.getNumCollo())
|
||||
.setSerCollo(mtbColtSession.getSerCollo())
|
||||
.setGestioneCollo(mtbColtSession.getGestione());
|
||||
|
||||
mtbColtsSessions.add(recoverDTO);
|
||||
updateLocalFile();
|
||||
return mtbColtsSessions.indexOf(recoverDTO);
|
||||
}
|
||||
|
||||
public static void closeSession(int ID) {
|
||||
mtbColtsSessions.remove(ID);
|
||||
updateLocalFile();
|
||||
}
|
||||
|
||||
|
||||
private static void updateLocalFile() {
|
||||
FileOutputStream outputStream;
|
||||
|
||||
Gson gson = new Gson();
|
||||
String jsonText = gson.toJson(mtbColtsSessions);
|
||||
|
||||
try {
|
||||
outputStream = mContext.openFileOutput(CommonConst.Files.RECOVER_COLLO_FILE, Context.MODE_PRIVATE);
|
||||
outputStream.write(jsonText.getBytes());
|
||||
outputStream.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
UtilityExceptions.defaultException(mContext, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -43,7 +43,6 @@ public class MainFragment extends Fragment implements ITitledFragment {
|
||||
private View mView;
|
||||
|
||||
public MainFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static MainFragment newInstance() {
|
||||
|
||||
@ -23,6 +23,7 @@ import it.integry.integrywmsnative.core.REST.consumers.ISimpleOperationCallback;
|
||||
import it.integry.integrywmsnative.core.REST.consumers.PrinterRESTConsumer;
|
||||
import it.integry.integrywmsnative.core.REST.model.DistribuzioneColloDTO;
|
||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
||||
import it.integry.integrywmsnative.core.data_recover.ColliDataRecover;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.model.CommonModelConsts;
|
||||
import it.integry.integrywmsnative.core.model.FiltroOrdineDTO;
|
||||
@ -74,6 +75,8 @@ public class VenditaOrdineInevasoViewModel implements IOnColloClosedCallback, IO
|
||||
private Integer defaultNumOrdOfUL = null;
|
||||
private Date defaultDataOrdOfUL = null;
|
||||
|
||||
private Integer mtbColtSessionID = null;
|
||||
|
||||
public VenditaOrdineInevasoViewModel(VenditaOrdineInevasoActivity activity, ArticoliInColloBottomSheetViewModel articoliInColloBottomSheetViewModel, List<PickingObjectDTO> pickingList, List<OrdineVenditaGroupedInevasoDTO> orders, List<MtbColt> colliRegistrati) {
|
||||
this.mActivity = activity;
|
||||
this.mArticoliInColloBottomSheetViewModel = articoliInColloBottomSheetViewModel;
|
||||
@ -654,6 +657,8 @@ public class VenditaOrdineInevasoViewModel implements IOnColloClosedCallback, IO
|
||||
@Override
|
||||
public void onSuccess(MtbColt value) {
|
||||
|
||||
mtbColtSessionID = ColliDataRecover.startNewSession(value);
|
||||
|
||||
value
|
||||
.setDisablePrint(disablePrint)
|
||||
.setMtbColr(new ObservableArrayList<>());
|
||||
@ -704,7 +709,9 @@ public class VenditaOrdineInevasoViewModel implements IOnColloClosedCallback, IO
|
||||
if(thereIsAnyRowInUL()) {
|
||||
updateDataFine(progress, () -> distribuisciCollo(progress, (generatedMtbColts) -> printCollo(progress)));
|
||||
} else {
|
||||
ColliDataRecover.closeSession(mtbColtSessionID);
|
||||
deleteCollo(progress);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -735,7 +742,11 @@ public class VenditaOrdineInevasoViewModel implements IOnColloClosedCallback, IO
|
||||
|
||||
MtbColt cloneMtbColt = (MtbColt) mArticoliInColloBottomSheetViewModel.mtbColt.get().clone();
|
||||
|
||||
ColliMagazzinoRESTConsumer.distribuisciCollo(cloneMtbColt, DistribuzioneColloDTO.CriterioDistribuzione.UPDATE, onComplete,
|
||||
ColliMagazzinoRESTConsumer.distribuisciCollo(cloneMtbColt, DistribuzioneColloDTO.CriterioDistribuzione.UPDATE,
|
||||
mtbColts -> {
|
||||
ColliDataRecover.closeSession(mtbColtSessionID);
|
||||
onComplete.run(mtbColts);
|
||||
},
|
||||
ex -> UtilityExceptions.defaultException(mActivity, ex, progress));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user