Correzioni Verifica Giacenze

This commit is contained in:
Giuseppe Scorrano 2025-03-14 18:19:09 +01:00
parent 80dac639da
commit 2db0027fff
12 changed files with 94 additions and 49 deletions

6
.idea/AndroidProjectSystem.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidProjectSystem">
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
</component>
</project>

View File

@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 18,
"identityHash": "68c96a8a7f0f544255553297d0206576",
"identityHash": "720c67adcc3f947a0c0ce04d4d04fbe9",
"entities": [
{
"tableName": "articoli_griglia",
@ -1208,7 +1208,7 @@
},
{
"tableName": "verifica_giacenze_rows",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`parent_id` INTEGER, `created_at` INTEGER DEFAULT CURRENT_TIMESTAMP, `cod_mart` TEXT, `partita_mag` TEXT, `descrizione` TEXT, `qta` REAL NOT NULL DEFAULT 0, `num_cnf` REAL NOT NULL DEFAULT 0, `qta_cnf` REAL NOT NULL DEFAULT 0, `scan_cod_barre` TEXT, `_id` INTEGER PRIMARY KEY AUTOINCREMENT, `remote_sync_date` INTEGER, FOREIGN KEY(`parent_id`) REFERENCES `verifica_giacenze`(`_id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`parent_id` INTEGER, `created_at` INTEGER DEFAULT CURRENT_TIMESTAMP, `cod_mart` TEXT, `partita_mag` TEXT, `descrizione` TEXT, `qta_in_giacenza` REAL NOT NULL DEFAULT 0, `qta` REAL NOT NULL DEFAULT 0, `num_cnf` REAL NOT NULL DEFAULT 0, `qta_cnf` REAL NOT NULL DEFAULT 0, `scan_cod_barre` TEXT, `_id` INTEGER PRIMARY KEY AUTOINCREMENT, `remote_sync_date` INTEGER, FOREIGN KEY(`parent_id`) REFERENCES `verifica_giacenze`(`_id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "parentId",
@ -1241,6 +1241,13 @@
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "qtaInGiacenza",
"columnName": "qta_in_giacenza",
"affinity": "REAL",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "qta",
"columnName": "qta",
@ -1325,7 +1332,7 @@
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '68c96a8a7f0f544255553297d0206576')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '720c67adcc3f947a0c0ce04d4d04fbe9')"
]
}
}

View File

@ -49,14 +49,14 @@ public class MainContext {
//this.initAuthSession(() -> {
this.initDeviceId(() -> {
// this.initDeviceId(() -> {
this.initDBData(() -> {
this.initMenu(() -> {
if (mListener != null) mListener.onContextInitialized();
});
});
});
// });
//});
@ -96,9 +96,9 @@ public class MainContext {
SettingsManager.i().getUserSession().setDeviceId(fid.getResult());
SettingsManager.update();
systemRESTConsumer.registerDevice(onComplete, ex -> {
if (mListener != null) mListener.onError(new SpannedString(ex.getMessage()));
});
// systemRESTConsumer.registerDevice(onComplete, ex -> {
// if (mListener != null) mListener.onError(new SpannedString(ex.getMessage()));
// });
});
}

View File

@ -206,6 +206,7 @@ public abstract class AppDatabase extends RoomDatabase {
"cod_mart TEXT, " +
"partita_mag TEXT, " +
"descrizione TEXT, " +
"qta_in_giacenza REAL NOT NULL DEFAULT 0, " +
"qta REAL NOT NULL DEFAULT 0, " +
"num_cnf REAL NOT NULL DEFAULT 0, " +
"qta_cnf REAL NOT NULL DEFAULT 0, " +

View File

@ -33,6 +33,7 @@ public class VerificaGiacenzeRowEntity extends BaseSyncDTO implements EntityMode
public static final String COD_MART = "cod_mart";
public static final String PARTITA_MAG = "partita_mag";
public static final String DESCRIZIONE = "descrizione";
public static final String QTA_IN_GIACENZA = "qta_in_giacenza";
public static final String QTA = "qta";
public static final String NUM_CNF = "num_cnf";
public static final String QTA_CNF = "qta_cnf";
@ -54,6 +55,10 @@ public class VerificaGiacenzeRowEntity extends BaseSyncDTO implements EntityMode
@ColumnInfo(name = Columns.DESCRIZIONE)
private String descrizione;
@NonNull
@ColumnInfo(name = Columns.QTA_IN_GIACENZA, defaultValue = "0")
private BigDecimal qtaInGiacenza;
@NonNull
@ColumnInfo(name = Columns.QTA, defaultValue = "0")
private BigDecimal qta;
@ -110,6 +115,15 @@ public class VerificaGiacenzeRowEntity extends BaseSyncDTO implements EntityMode
this.descrizione = descrizione;
}
@NonNull
public BigDecimal getQtaInGiacenza() {
return qtaInGiacenza;
}
public void setQtaInGiacenza(@NonNull BigDecimal qtaInGiacenza) {
this.qtaInGiacenza = qtaInGiacenza;
}
@NonNull
public BigDecimal getQta() {
return qta;

View File

@ -15,6 +15,7 @@ public class VerificaGiacenzeRowMapper extends BaseMapper<VerificaGiacenzeRowDTO
var data = new VerificaGiacenzeRowEntity();
data.setCodMart(inputData.getCodMart());
data.setPartitaMag(inputData.getPartitaMag());
data.setQtaInGiacenza(inputData.getQtaInGiacenza());
data.setQta(inputData.getQta());
data.setNumConf(inputData.getNumCnf());
data.setQtaConf(inputData.getQtaCnf());
@ -29,6 +30,7 @@ public class VerificaGiacenzeRowMapper extends BaseMapper<VerificaGiacenzeRowDTO
var data = new VerificaGiacenzeRowDTO();
data.setCodMart(inputData.getCodMart());
data.setPartitaMag(inputData.getPartitaMag());
data.setQtaInGiacenza(inputData.getQtaInGiacenza());
data.setQta(inputData.getQta());
data.setNumCnf(inputData.getNumConf());
data.setQtaCnf(inputData.getQtaConf());

View File

@ -27,7 +27,6 @@ import it.integry.integrywmsnative.core.rest.model.MailRequestDTO;
import it.integry.integrywmsnative.core.rest.model.NativeSqlRequestDTO;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.system.LatestAppVersionInfoDTO;
import it.integry.integrywmsnative.core.rest.model.system.RegisterDeviceRequestDTO;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityGson;
import it.integry.integrywmsnative.core.utility.UtilityString;
@ -57,27 +56,6 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
return analyzeAnswerGeneric(response, "updates");
}
public void registerDevice(final Runnable onSuccess, final RunnableArgs<Exception> onFailed) {
RegisterDeviceRequestDTO registerDeviceRequestDTO = new RegisterDeviceRequestDTO()
.setApp("WMS");
SystemRESTConsumerService systemRESTConsumerService = restBuilder.getService(SystemRESTConsumerService.class);
systemRESTConsumerService.registerDevice(registerDeviceRequestDTO)
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<Void>> call, Response<ServiceRESTResponse<Void>> response) {
analyzeAnswer(response, "device/register", Void -> onSuccess.run(), onFailed);
}
@Override
public void onFailure(Call<ServiceRESTResponse<Void>> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
}
public <T> T processSqlSynchronized(String nativeSql, final Type clazz) throws Exception {
NativeSqlRequestDTO nativeSqlDTO = new NativeSqlRequestDTO()
.setNativeSql(nativeSql);

View File

@ -7,7 +7,6 @@ import it.integry.integrywmsnative.core.rest.model.MailRequestDTO;
import it.integry.integrywmsnative.core.rest.model.NativeSqlRequestDTO;
import it.integry.integrywmsnative.core.rest.model.ServiceRESTResponse;
import it.integry.integrywmsnative.core.rest.model.system.LatestAppVersionInfoDTO;
import it.integry.integrywmsnative.core.rest.model.system.RegisterDeviceRequestDTO;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
@ -19,9 +18,6 @@ public interface SystemRESTConsumerService {
@GET("wms/currentVersion")
Call<LatestAppVersionInfoDTO> retrieveUpdatesInfo(@Query("suffix") String suffix);
@POST("device/register")
Call<ServiceRESTResponse<Void>> registerDevice(@Body RegisterDeviceRequestDTO registerDeviceRequestDTO);
@POST("processSql")
Call<ServiceRESTResponse<Object>> processSql(@Body NativeSqlRequestDTO nativeSqlDTO);

View File

@ -8,6 +8,7 @@ public class VerificaGiacenzeRowDTO extends BaseRestDTO {
private String codMart;
private String partitaMag;
private BigDecimal qtaInGiacenza;
private BigDecimal qta;
private BigDecimal qtaCnf;
private BigDecimal numCnf;
@ -31,6 +32,14 @@ public class VerificaGiacenzeRowDTO extends BaseRestDTO {
return this;
}
public BigDecimal getQtaInGiacenza() {
return qtaInGiacenza;
}
public void setQtaInGiacenza(BigDecimal qtaInGiacenza) {
this.qtaInGiacenza = qtaInGiacenza;
}
public BigDecimal getQta() {
return qta;
}

View File

@ -1,15 +0,0 @@
package it.integry.integrywmsnative.core.rest.model.system;
public class RegisterDeviceRequestDTO {
private String app;
public String getApp() {
return app;
}
public RegisterDeviceRequestDTO setApp(String app) {
this.app = app;
return this;
}
}

View File

@ -141,6 +141,13 @@ public class VerificaGiacenzeFragment extends BaseFragment implements ITitledFra
this.initRecyclerView();
this.initBarcodeReader();
this.onLoadingStarted();
executorService.execute(() -> {
mViewModel.randomizeElements(2000);
this.onLoadingEnded();
});
});
}

View File

@ -114,6 +114,40 @@ public class VerificaGiacenzeViewModel {
currentLoadedAnagrafiche.forEach(x -> x.setFlagTracciabilita("N"));
}
public void randomizeElements(int elementsCount) {
for(int i = 0; i < elementsCount; i++) {
var randomIndex = (int) (Math.random() * currentLoadedAnagrafiche.size());
var randomAnagrafica = currentLoadedAnagrafiche.get(randomIndex);
var foundGiacenza = currentLoadedGiacenza.parallelStream()
.filter(x -> x.getCodMart().equalsIgnoreCase(randomAnagrafica.getCodMart()))
.findFirst()
.orElse(null);
var qtaGiacenza = foundGiacenza != null ? foundGiacenza.getQtaInv() : BigDecimal.ZERO;
var rowToInsert = new VerificaGiacenzeRowEntity();
rowToInsert.setParentId(currentVerifica.getValue().getId());
rowToInsert.setCodMart(randomAnagrafica.getCodMart());
rowToInsert.setDescrizione(randomAnagrafica.getDescrizione());
rowToInsert.setScanCodBarre(randomAnagrafica.getBarCode());
rowToInsert.setNumConf(BigDecimal.valueOf((int) (Math.random() * 100)));
rowToInsert.setQtaConf(randomAnagrafica.getQtaCnf());
rowToInsert.setQta(UtilityBigDecimal.multiply(rowToInsert.getNumConf(), randomAnagrafica.getQtaCnf()));
rowToInsert.setQtaInGiacenza(qtaGiacenza);
insertRow(rowToInsert);
try {
Thread.sleep(50);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
public void createNew(String codMdep) {
var verificaGiacenzeEntity = new VerificaGiacenzeEntity();
verificaGiacenzeEntity.setCodMdep(codMdep);
@ -134,6 +168,11 @@ public class VerificaGiacenzeViewModel {
public void save() throws Exception {
if(currentVerificaRows.getValue().isEmpty()) {
delete();
return;
}
currentVerifica.getValue().setVerificaGiacenzeRowList(currentVerificaRows.getValue());
SaveNewVerificaRequestDTO saveRequest = new SaveNewVerificaRequestDTO()
@ -223,6 +262,7 @@ public class VerificaGiacenzeViewModel {
rowToSave.setNumConf(pickedQuantity.getNumCnf());
rowToSave.setQtaConf(pickedQuantity.getQtaCnf());
rowToSave.setQta(pickedQuantity.getQtaTot());
rowToSave.setQtaInGiacenza(qtaGiacenza);
if (isNewRow) {
insertRow(rowToSave);