aggiunte condizioni per l'autocompletamento delle tipo pedana in rientro merce

This commit is contained in:
Valerio Castellana 2022-07-22 11:21:08 +02:00
parent 0c3d5bd0f1
commit 7c49af085d
2 changed files with 43 additions and 27 deletions

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="20119B1E55" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-07-21T14:57:04.221380200Z" />
</component>
</project>

View File

@ -18,6 +18,7 @@ import androidx.lifecycle.MutableLiveData;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.annimon.stream.ComparatorCompat;
import com.annimon.stream.Stream;
import com.google.gson.reflect.TypeToken;
import com.harrysoft.androidbluetoothserial.BluetoothManager;
@ -43,6 +44,7 @@ import it.integry.integrywmsnative.core.model.MtbColt;
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
import it.integry.integrywmsnative.core.utility.UtilityDB;
import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.databinding.FragmentProdRientroMerceOrderDetailBinding;
import it.integry.integrywmsnative.gest.prod_versamento_materiale.dto.OrdineLavorazioneDTO;
import it.integry.integrywmsnative.gest.settings.MainSettingsFragment;
@ -76,6 +78,7 @@ public class ProdRientroMerceOrderDetailFragment extends BaseFragment implements
private BluetoothManager bluetoothManager;
private BluetoothSerialDevice mConnectedBluetoothDevice;
private String mLatestCodTcol;
public ObservableField<BigDecimal> sumLUNumber = new ObservableField<>(BigDecimal.ZERO);
@ -182,6 +185,7 @@ public class ProdRientroMerceOrderDetailFragment extends BaseFragment implements
@Override
public void onDetach() {
mLatestCodTcol = null;
if (mConnectedBluetoothDevice != null)
bluetoothManager.close();
@ -207,13 +211,28 @@ public class ProdRientroMerceOrderDetailFragment extends BaseFragment implements
AtomicBigDecimal sumColli = new AtomicBigDecimal(BigDecimal.ZERO);
AtomicBigDecimal sumNet = new AtomicBigDecimal(BigDecimal.ZERO);
AtomicBigDecimal sumGross = new AtomicBigDecimal(BigDecimal.ZERO);
AtomicBigDecimal sumQtaCol = new AtomicBigDecimal(BigDecimal.ZERO);
Stream.of(mtbColts)
.forEach(x -> Stream.of(x.getMtbColr()).forEach(y -> {
sumColli.getAndAdd(y.getNumCnf());
sumNet.getAndAdd(y.getPesoNettoKg());
sumGross.getAndAdd(y.getPesoLordoKg());
sumQtaCol.getAndAdd(y.getQtaCol());
}));
ComparatorCompat<MtbColt> c = ComparatorCompat
.chain(
new ComparatorCompat<MtbColt>((x, y) -> x.getDataVersD().compareTo(y.getDataVersD()))
)
.reversed();
MtbColt lastUl = Stream.of(mtbColts).sorted(c).findFirstOrElse(null);
if (lastUl != null && !UtilityString.isNullOrEmpty(lastUl.getCodTcol())) {
mLatestCodTcol = lastUl.getCodTcol();
}
currentOrder.getValue().setQtaTrasferite(sumQtaCol.get());
this.progress.set(currentOrder.getValue().getProgress());
sumColliNumber.set(sumColli.get());
sumGrossKG.set(sumGross.get());
progress.set(currentOrder.getValue().getProgress());
@ -237,7 +256,12 @@ public class ProdRientroMerceOrderDetailFragment extends BaseFragment implements
public void addULButtonClick() {
this.onLoadingStarted();
String codProd = this.currentOrder.getValue().getCodProd();
OrdineLavorazioneDTO currentOrder = this.currentOrder.getValue();
if (currentOrder == null) {
this.onError(new Exception("Nessun ordine rilevato!"));
return;
}
String codProd = currentOrder.getCodProd();
mArticoloRESTConsumer.getByCodMart(codProd, mtbAart -> {
String sql = "SELECT TOP 1 * " +
@ -246,9 +270,9 @@ public class ProdRientroMerceOrderDetailFragment extends BaseFragment implements
" * " +
" FROM dtb_ord_steps " +
" WHERE cod_jfas IS NOT NULL " +
" AND gestione = " + UtilityDB.valueToString(this.currentOrder.getValue().getGestione()) +
" AND num_ord = " + UtilityDB.valueToString(this.currentOrder.getValue().getNumOrd()) +
" AND data_ord = " + UtilityDB.valueToString(this.currentOrder.getValue().getDataOrdD()) +
" AND gestione = " + UtilityDB.valueToString(currentOrder.getGestione()) +
" AND num_ord = " + UtilityDB.valueToString(currentOrder.getNumOrd()) +
" AND data_ord = " + UtilityDB.valueToString(currentOrder.getDataOrdD()) +
" ) tmp " +
"WHERE data_iniz IS NOT NULL " +
" AND (data_fine IS NULL OR last_step = id_step) " +
@ -259,15 +283,24 @@ public class ProdRientroMerceOrderDetailFragment extends BaseFragment implements
this.onLoadingEnded();
String codTcol = currentOrder.getCodTcolUl();
if (UtilityString.isNullOrEmpty(codTcol)) {
if (!UtilityString.isNullOrEmpty(mLatestCodTcol)) {
codTcol = mLatestCodTcol;
} else {
codTcol = mtbAart.getCodTcolUl();
}
}
DialogInputLUProdDTO dialogInputLUProdDTO = new DialogInputLUProdDTO()
.setMtbAart(mtbAart)
.setNumCnf(this.currentOrder.getValue().getColliPedana())
.setNumCnf(currentOrder.getColliPedana())
.setQtaCnf(mtbAart.getQtaCnf())
.setQtaTot(this.currentOrder.getValue().getColliPedana().multiply(mtbAart.getQtaCnf()))
.setPartitaMag(this.currentOrder.getValue().getPartitaMag())
.setDataScad(this.currentOrder.getValue().getDataScadD())
.setCodJfasParent(this.currentOrder.getValue().getCodJfas())
.setCodTcol(this.currentOrder.getValue().getCodTcolUl())
.setQtaTot(currentOrder.getColliPedana().multiply(mtbAart.getQtaCnf()))
.setPartitaMag(currentOrder.getPartitaMag())
.setDataScad(currentOrder.getDataScadD())
.setCodJfasParent(currentOrder.getCodJfas())
.setCodTcol(codTcol)
.setSuggestedCodJfas(dtbOrdStep != null && dtbOrdStep.size() > 0 ? dtbOrdStep.get(0).getCodJfas() : null);