Completata procedura di recupero materiale da produzione.

This commit is contained in:
Giuseppe Scorrano 2020-01-03 15:30:50 +01:00
parent eb3f19cb2e
commit baf23c37e4
6 changed files with 600 additions and 121 deletions

View File

@ -310,8 +310,8 @@ public class PickingResiActivity extends BaseActivity implements IOnColloClosedC
.setSerDoc(item.getSerDoc()) .setSerDoc(item.getSerDoc())
.setNumDoc(item.getNumDoc()) .setNumDoc(item.getNumDoc())
.setDataDoc(item.getDataDocS()) .setDataDoc(item.getDataDocS())
.setIdRigaDoc(item.getIdRiga()) .setIdRigaDoc(item.getIdRiga());
.setCodJcom(item.getCodJcom()); // .setCodJcom(item.getCodJcom());

View File

@ -18,20 +18,21 @@ import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.utility.UtilityString; import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.databinding.ProdRecuperoMaterialeListHeaderBinding; import it.integry.integrywmsnative.databinding.ProdRecuperoMaterialeListHeaderBinding;
import it.integry.integrywmsnative.databinding.ProdRecuperoMaterialeListItemBinding; import it.integry.integrywmsnative.databinding.ProdRecuperoMaterialeListItemBinding;
import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdUL; import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdULDTO;
import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdULDTO;
import it.integry.integrywmsnative.ui.fastscroll.SectionTitleProvider; import it.integry.integrywmsnative.ui.fastscroll.SectionTitleProvider;
public class HistoryULsListAdapter extends SectionedRecyclerViewAdapter<HistoryULsListAdapter.SubheaderHolder, HistoryULsListAdapter.SingleItemViewHolder> implements SectionTitleProvider { public class HistoryULsListAdapter extends SectionedRecyclerViewAdapter<HistoryULsListAdapter.SubheaderHolder,HistoryULsListAdapter.SingleItemViewHolder> implements SectionTitleProvider {
private Context mContext; private Context mContext;
private List<HistoryVersamentoProdUL> mOriginalDataset; private List<HistoryVersamentoProdULDTO> mOriginalDataset;
private List<HistoryVersamentoProdUL> mDataset; private List<HistoryVersamentoProdULDTO> mDataset;
private View mEmptyView; private View mEmptyView;
private RunnableArgs<HistoryVersamentoProdUL> mOnItemClicked; private RunnableArgs<HistoryVersamentoProdULDTO> mOnItemClicked;
static class SubheaderHolder extends RecyclerView.ViewHolder { static class SubheaderHolder extends RecyclerView.ViewHolder {
@ -56,18 +57,18 @@ public class HistoryULsListAdapter extends SectionedRecyclerViewAdapter<HistoryU
public HistoryULsListAdapter(Context context, List<HistoryVersamentoProdUL> myDataset, View emptyView) { public HistoryULsListAdapter(Context context, List<HistoryVersamentoProdULDTO> myDataset, View emptyView) {
mContext = context; mContext = context;
mOriginalDataset = myDataset; mOriginalDataset = myDataset;
mEmptyView = emptyView; mEmptyView = emptyView;
mDataset = orderItems(myDataset); mDataset = orderItems(myDataset);
} }
public void setOnItemClicked(RunnableArgs<HistoryVersamentoProdUL> onItemClicked) { public void setOnItemClicked(RunnableArgs<HistoryVersamentoProdULDTO> onItemClicked) {
this.mOnItemClicked = onItemClicked; this.mOnItemClicked = onItemClicked;
} }
public void updateItems(List<HistoryVersamentoProdUL> updatedDataset) { public void updateItems(List<HistoryVersamentoProdULDTO> updatedDataset) {
mDataset.clear(); mDataset.clear();
mDataset.addAll(orderItems(updatedDataset)); mDataset.addAll(orderItems(updatedDataset));
notifyDataChanged(); notifyDataChanged();
@ -76,9 +77,9 @@ public class HistoryULsListAdapter extends SectionedRecyclerViewAdapter<HistoryU
} }
private List<HistoryVersamentoProdUL> orderItems(List<HistoryVersamentoProdUL> dataset) { private List<HistoryVersamentoProdULDTO> orderItems(List<HistoryVersamentoProdULDTO> dataset) {
return Stream.of(dataset) return Stream.of(dataset)
.sortBy(HistoryVersamentoProdUL::getCodJfas) .sortBy(HistoryVersamentoProdULDTO::getCodJfas)
.toList(); .toList();
} }
@ -109,7 +110,7 @@ public class HistoryULsListAdapter extends SectionedRecyclerViewAdapter<HistoryU
@Override @Override
public void onBindItemViewHolder(SingleItemViewHolder h, int itemPosition) { public void onBindItemViewHolder(SingleItemViewHolder h, int itemPosition) {
final HistoryVersamentoProdUL ul = mDataset.get(itemPosition); final HistoryVersamentoProdULDTO ul = mDataset.get(itemPosition);
final SingleItemViewHolder holder = h; final SingleItemViewHolder holder = h;

View File

@ -6,7 +6,9 @@ import com.annimon.stream.Stream;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import it.integry.integrywmsnative.core.model.MtbAart; import it.integry.integrywmsnative.core.model.MtbAart;
@ -14,7 +16,8 @@ import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ISimpleOperationCallback; import it.integry.integrywmsnative.core.rest.consumers.ISimpleOperationCallback;
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer; import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
import it.integry.integrywmsnative.core.expansion.RunnableArgs; import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdUL; import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdULDTO;
import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdULRestDTO;
public class ProdRecuperoMaterialeHelper { public class ProdRecuperoMaterialeHelper {
@ -26,73 +29,163 @@ public class ProdRecuperoMaterialeHelper {
} }
public void loadLastULVersate(RunnableArgs<List<HistoryVersamentoProdUL>> onComplete, RunnableArgs<Exception> onFailed) { public void loadLastULVersate(RunnableArgs<List<HistoryVersamentoProdULDTO>> onComplete, RunnableArgs<Exception> onFailed) {
String sql = "SELECT jtb_fasi.cod_jfas, " + String sql = "SELECT jtb_fasi.cod_jfas, " +
"jtb_fasi.descrizione AS descrizione_fase, " + " jtb_fasi.descrizione AS descrizione_fase, " +
"mtb_colr.gestione, " + " mtb_colr.gestione, " +
"mtb_colr.data_collo, " + " mtb_colr.data_collo, " +
"mtb_colr.num_collo, " + " mtb_colr.num_collo, " +
"mtb_colr.ser_collo, " + " mtb_colr.ser_collo, " +
"mtb_colr.cod_mart, " + " mtb_colr.cod_mart, " +
"mtb_colr.cod_col, " + " mtb_colr.cod_col, " +
"mtb_colr.cod_tagl, " + " mtb_colr.cod_tagl, " +
"SUM(mtb_colr.qta_col) AS qta_col, " + " SUM(mtb_colr.qta_col) AS qta_col, " +
"SUM(mtb_colr.num_cnf) AS num_cnf, " + " SUM(mtb_colr.num_cnf) AS num_cnf, " +
"mtb_colr.ser_collo, " + " mtb_colr.ser_collo, " +
"mtb_colr.partita_mag, " + " mtb_colr.partita_mag, " +
"mtb_colr.cod_jcom, " + " mtb_colr.cod_jcom, " +
"mtb_colr.num_collo_rif, " + " mtb_colr.num_collo_rif, " +
"mtb_colr.data_collo_rif, " + " mtb_colr.data_collo_rif, " +
"mtb_colr.ser_collo_rif, " + " mtb_colr.ser_collo_rif, " +
"mtb_colr.gestione_rif, " + " mtb_colr.gestione_rif, " +
"mtb_colt.segno, " + " mtb_colt.segno, " +
"ISNULL(mtb_aart.descrizione_estesa, mtb_aart.descrizione) AS descrizione_art, " + " ISNULL(mtb_aart.descrizione_estesa, mtb_aart.descrizione) AS descrizione_art, " +
"mtb_aart.unt_mis, " + " mtb_aart.unt_mis, " +
"MAX(datetime_row) AS datetime_row " + " MAX(datetime_row) AS datetime_row, " +
" dtb_ord_steps.num_ord, " +
" dtb_ord_steps.data_ord, " +
" dtb_ord_steps.gestione as gestione_ord, " +
" dtb_ord_steps.hr_num as hr, " +
" mtb_colr.riga_ord, " +
" CONVERT(INTEGER, ROUND((CAST(dtb_ord_steps.hr_num AS DECIMAL(20, 5)) / SUM(dtb_ord_steps.hr_num) OVER (PARTITION BY mtb_colr.num_collo)) * 100, 0)) as percentage_hr " +
"FROM mtb_colr " + "FROM mtb_colr " +
"INNER JOIN mtb_colt " + "INNER JOIN mtb_colt ON mtb_colr.num_collo = mtb_colt.num_collo " +
"ON mtb_colr.num_collo = mtb_colt.num_collo " +
"AND mtb_colr.data_collo = mtb_colt.data_collo " + "AND mtb_colr.data_collo = mtb_colt.data_collo " +
"AND mtb_colr.ser_collo = mtb_colt.ser_collo " + "AND mtb_colr.ser_collo = mtb_colt.ser_collo " +
"AND mtb_colr.gestione = mtb_colt.gestione " + "AND mtb_colr.gestione = mtb_colt.gestione " +
"INNER JOIN mtb_aart " + " " +
"ON mtb_colr.cod_mart = mtb_aart.cod_mart " + "INNER JOIN dtb_ord_steps ON dtb_ord_steps.data_ord = mtb_colr.data_ord " +
" AND dtb_ord_steps.gestione = mtb_colr.gestione " +
" AND dtb_ord_steps.num_ord = mtb_colr.num_ord " +
" AND dtb_ord_steps.data_iniz is not null " +
" AND dtb_ord_steps.data_fine is null " +
"INNER JOIN mtb_aart ON mtb_colr.cod_mart = mtb_aart.cod_mart " +
"LEFT OUTER JOIN jtb_fasi ON mtb_colt.cod_jfas = jtb_fasi.cod_jfas " + "LEFT OUTER JOIN jtb_fasi ON mtb_colt.cod_jfas = jtb_fasi.cod_jfas " +
"WHERE jtb_fasi.cod_jfas IS NOT NULL " + "WHERE jtb_fasi.cod_jfas IS NOT NULL " +
"AND segno = -1 " + " AND segno = -1 " +
"AND mtb_colr.data_collo > DATEADD(DAY, -1, GETDATE()) " + " AND mtb_colr.data_collo > DATEADD(DAY, -1, GETDATE()) " +
"GROUP BY jtb_fasi.cod_jfas, " + "GROUP BY jtb_fasi.cod_jfas, " +
"jtb_fasi.descrizione, " + " jtb_fasi.descrizione, " +
"mtb_colr.gestione, " + " mtb_colr.gestione, " +
"mtb_colr.data_collo, " + " mtb_colr.data_collo, " +
"mtb_colr.num_collo, " + " mtb_colr.num_collo, " +
"mtb_colr.ser_collo, " + " mtb_colr.ser_collo, " +
"mtb_colr.cod_mart, " + " mtb_colr.cod_mart, " +
"mtb_colr.cod_col, " + " mtb_colr.cod_col, " +
"mtb_colr.cod_tagl, " + " mtb_colr.cod_tagl, " +
"mtb_colr.ser_collo, " + " mtb_colr.ser_collo, " +
"mtb_colr.partita_mag, " + " mtb_colr.partita_mag, " +
"mtb_colr.cod_jcom, " + " mtb_colr.cod_jcom, " +
"mtb_aart.descrizione_estesa, " + " mtb_aart.descrizione_estesa, " +
"mtb_aart.descrizione, " + " mtb_aart.descrizione, " +
"mtb_aart.unt_mis, " + " mtb_aart.unt_mis, " +
"mtb_colr.num_collo_rif, " + " mtb_colr.num_collo_rif, " +
"mtb_colr.data_collo_rif, " + " mtb_colr.data_collo_rif, " +
"mtb_colr.ser_collo_rif, " + " mtb_colr.ser_collo_rif, " +
"mtb_colr.gestione_rif, " + " mtb_colr.gestione_rif, " +
"mtb_colt.segno " + " mtb_colt.segno, " +
" dtb_ord_steps.num_ord, " +
" dtb_ord_steps.data_ord, " +
" dtb_ord_steps.gestione, " +
" mtb_colr.riga_ord, " +
" dtb_ord_steps.hr_num " +
"HAVING SUM(mtb_colr.qta_col) > 0 " + "HAVING SUM(mtb_colr.qta_col) > 0 " +
"ORDER BY data_collo DESC"; "ORDER BY data_collo DESC";
Type typeOfObjectsList = new TypeToken<ArrayList<HistoryVersamentoProdUL>>() {}.getType(); Type typeOfObjectsList = new TypeToken<ArrayList<HistoryVersamentoProdULRestDTO>>() {}.getType();
SystemRESTConsumer.processSql(sql, typeOfObjectsList, new ISimpleOperationCallback<List<HistoryVersamentoProdUL>>() { SystemRESTConsumer.processSql(sql, typeOfObjectsList, new ISimpleOperationCallback<List<HistoryVersamentoProdULRestDTO>>() {
@Override @Override
public void onSuccess(List<HistoryVersamentoProdUL> ulList) { public void onSuccess(List<HistoryVersamentoProdULRestDTO> ulList) {
if(ulList != null && ulList.size() > 0){ if(ulList == null) {
List<String> codMarts = Stream.of(ulList) onComplete.run(null);
.map(HistoryVersamentoProdUL::getCodMart) return;
}
List<HistoryVersamentoProdULDTO> newUlList = new ArrayList<>();
Stream.of(ulList)
.distinctBy(x -> {
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("gestione", x.getGestione());
hashMap.put("data_collo", x.getDataCollo());
hashMap.put("ser_collo", x.getSerCollo());
hashMap.put("num_collo", x.getNumCollo());
hashMap.put("cod_mart", x.getCodMart());
hashMap.put("gestione_rif", x.getGestioneRif());
hashMap.put("data_collo_rif", x.getDataColloRif());
hashMap.put("ser_collo_rif", x.getSerColloRif());
hashMap.put("num_collo_rif", x.getNumColloRif());
return hashMap;
})
.forEach(restDTO -> {
List<HistoryVersamentoProdULDTO.OrdineDto> ordineList = Stream.of(ulList)
.filter(x -> x.getNumCollo().equals(restDTO.getNumCollo()) &&
x.getDataCollo().equals(restDTO.getDataCollo()) &&
x.getSerCollo().equals(restDTO.getSerCollo()) &&
x.getGestione().equals(restDTO.getGestione()))
.map(x -> new HistoryVersamentoProdULDTO.OrdineDto()
.setData(x.getDataOrdD())
.setNumero(x.getNumOrd())
.setGestione(x.getGestioneOrd())
.setRigaOrd(x.getRigaOrd())
.setQtaCol(x.getQtaCol())
.setNumCnf(x.getNumCnf())
.setPercentageHr(x.getPercentageHr()))
.toList();
BigDecimal qtaColTot = BigDecimal.ZERO;
BigDecimal numCnfColTot = BigDecimal.ZERO;
for (HistoryVersamentoProdULDTO.OrdineDto ordine :
ordineList) {
qtaColTot = qtaColTot.add(ordine.getQtaCol());
numCnfColTot = numCnfColTot.add(ordine.getNumCnf());
}
newUlList.add(new HistoryVersamentoProdULDTO()
.setGestione(restDTO.getGestione())
.setDataCollo(restDTO.getDataCollo())
.setSerCollo(restDTO.getSerCollo())
.setNumCollo(restDTO.getNumCollo())
.setSegno(restDTO.getSegno())
.setCodMart(restDTO.getCodMart())
.setCodCol(restDTO.getCodCol())
.setCodTagl(restDTO.getCodTagl())
.setCodJfas(restDTO.getCodJfas())
.setDescrizioneFase(restDTO.getDescrizioneFase())
.setQtaCol(qtaColTot)
.setNumCnf(numCnfColTot)
.setPartitaMag(restDTO.getPartitaMag())
.setCodJcom(restDTO.getCodJcom())
.setDatetimeRow(restDTO.getDatetimeRow())
.setUntMis(restDTO.getUntMis())
.setGestioneRif(restDTO.getGestioneRif())
.setDataColloRif(restDTO.getDataColloRif())
.setSerColloRif(restDTO.getSerColloRif())
.setNumColloRif(restDTO.getNumColloRif())
.setOrdini(ordineList));
});
if(newUlList.size() > 0){
List<String> codMarts = Stream.of(newUlList)
.map(HistoryVersamentoProdULDTO::getCodMart)
.withoutNulls() .withoutNulls()
.distinct() .distinct()
.toList(); .toList();
@ -100,7 +193,7 @@ public class ProdRecuperoMaterialeHelper {
ArticoloRESTConsumer.getByCodMart(codMarts, arts -> { ArticoloRESTConsumer.getByCodMart(codMarts, arts -> {
if(arts != null && arts.size() > 0) { if(arts != null && arts.size() > 0) {
for (HistoryVersamentoProdUL value : ulList) { for (HistoryVersamentoProdULDTO value : newUlList) {
MtbAart foundMtbAart = null; MtbAart foundMtbAart = null;
@ -113,15 +206,14 @@ public class ProdRecuperoMaterialeHelper {
value.setMtbAart(foundMtbAart); value.setMtbAart(foundMtbAart);
} }
onComplete.run(ulList);
} }
onComplete.run(newUlList);
}, onFailed); }, onFailed);
} else { } else {
onComplete.run(ulList); onComplete.run(newUlList);
} }
} }

View File

@ -0,0 +1,325 @@
package it.integry.integrywmsnative.gest.prod_recupero_materiale.dto;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.List;
import it.integry.integrywmsnative.core.model.MtbAart;
public class HistoryVersamentoProdULDTO {
private String gestione;
private String dataCollo;
private String serCollo;
private Integer numCollo;
private String segno;
private String codMart;
private String codCol;
private String codTagl;
private String codJfas;
private String descrizioneFase;
private BigDecimal qtaCol;
private BigDecimal numCnf;
private String partitaMag;
private String codJcom;
private String datetimeRow;
private String descrizioneArt;
private String untMis;
private String gestioneRif;
private String dataColloRif;
private String serColloRif;
private Integer numColloRif;
private List<HistoryVersamentoProdULDTO.OrdineDto> ordini;
private MtbAart mtbAart;
public BigDecimal getQtaCnf() {
return qtaCol.divide(numCnf, 3, RoundingMode.HALF_EVEN);
}
public String getGestione() {
return gestione;
}
public HistoryVersamentoProdULDTO setGestione(String gestione) {
this.gestione = gestione;
return this;
}
public String getDataCollo() {
return dataCollo;
}
public HistoryVersamentoProdULDTO setDataCollo(String dataCollo) {
this.dataCollo = dataCollo;
return this;
}
public String getSerCollo() {
return serCollo;
}
public HistoryVersamentoProdULDTO setSerCollo(String serCollo) {
this.serCollo = serCollo;
return this;
}
public Integer getNumCollo() {
return numCollo;
}
public HistoryVersamentoProdULDTO setNumCollo(Integer numCollo) {
this.numCollo = numCollo;
return this;
}
public String getSegno() {
return segno;
}
public HistoryVersamentoProdULDTO setSegno(String segno) {
this.segno = segno;
return this;
}
public String getCodMart() {
return codMart;
}
public HistoryVersamentoProdULDTO setCodMart(String codMart) {
this.codMart = codMart;
return this;
}
public String getCodCol() {
return codCol;
}
public HistoryVersamentoProdULDTO setCodCol(String codCol) {
this.codCol = codCol;
return this;
}
public String getCodTagl() {
return codTagl;
}
public HistoryVersamentoProdULDTO setCodTagl(String codTagl) {
this.codTagl = codTagl;
return this;
}
public String getCodJfas() {
return codJfas;
}
public HistoryVersamentoProdULDTO setCodJfas(String codJfas) {
this.codJfas = codJfas;
return this;
}
public String getDescrizioneFase() {
return descrizioneFase;
}
public HistoryVersamentoProdULDTO setDescrizioneFase(String descrizioneFase) {
this.descrizioneFase = descrizioneFase;
return this;
}
public BigDecimal getQtaCol() {
return qtaCol;
}
public HistoryVersamentoProdULDTO setQtaCol(BigDecimal qtaCol) {
this.qtaCol = qtaCol;
return this;
}
public BigDecimal getNumCnf() {
return numCnf;
}
public HistoryVersamentoProdULDTO setNumCnf(BigDecimal numCnf) {
this.numCnf = numCnf;
return this;
}
public String getPartitaMag() {
return partitaMag;
}
public HistoryVersamentoProdULDTO setPartitaMag(String partitaMag) {
this.partitaMag = partitaMag;
return this;
}
public String getCodJcom() {
return codJcom;
}
public HistoryVersamentoProdULDTO setCodJcom(String codJcom) {
this.codJcom = codJcom;
return this;
}
public String getDatetimeRow() {
return datetimeRow;
}
public HistoryVersamentoProdULDTO setDatetimeRow(String datetimeRow) {
this.datetimeRow = datetimeRow;
return this;
}
public String getDescrizioneArt() {
return descrizioneArt;
}
public HistoryVersamentoProdULDTO setDescrizioneArt(String descrizioneArt) {
this.descrizioneArt = descrizioneArt;
return this;
}
public String getUntMis() {
return untMis;
}
public HistoryVersamentoProdULDTO setUntMis(String untMis) {
this.untMis = untMis;
return this;
}
public String getGestioneRif() {
return gestioneRif;
}
public HistoryVersamentoProdULDTO setGestioneRif(String gestioneRif) {
this.gestioneRif = gestioneRif;
return this;
}
public String getDataColloRif() {
return dataColloRif;
}
public HistoryVersamentoProdULDTO setDataColloRif(String dataColloRif) {
this.dataColloRif = dataColloRif;
return this;
}
public String getSerColloRif() {
return serColloRif;
}
public HistoryVersamentoProdULDTO setSerColloRif(String serColloRif) {
this.serColloRif = serColloRif;
return this;
}
public Integer getNumColloRif() {
return numColloRif;
}
public HistoryVersamentoProdULDTO setNumColloRif(Integer numColloRif) {
this.numColloRif = numColloRif;
return this;
}
public List<OrdineDto> getOrdini() {
return ordini;
}
public HistoryVersamentoProdULDTO setOrdini(List<OrdineDto> ordini) {
this.ordini = ordini;
return this;
}
public MtbAart getMtbAart() {
return mtbAart;
}
public HistoryVersamentoProdULDTO setMtbAart(MtbAart mtbAart) {
this.mtbAart = mtbAart;
return this;
}
public static class OrdineDto {
private Integer numero;
private Date data;
private String gestione;
private Integer rigaOrd;
private BigDecimal qtaCol;
private BigDecimal numCnf;
private Integer percentageHr;
public BigDecimal getQtaCnf() {
return qtaCol.divide(numCnf, 3, RoundingMode.HALF_EVEN);
}
public Integer getNumero() {
return numero;
}
public HistoryVersamentoProdULDTO.OrdineDto setNumero(Integer numero) {
this.numero = numero;
return this;
}
public Date getData() {
return data;
}
public HistoryVersamentoProdULDTO.OrdineDto setData(Date data) {
this.data = data;
return this;
}
public String getGestione() {
return gestione;
}
public HistoryVersamentoProdULDTO.OrdineDto setGestione(String gestione) {
this.gestione = gestione;
return this;
}
public Integer getRigaOrd() {
return rigaOrd;
}
public OrdineDto setRigaOrd(Integer rigaOrd) {
this.rigaOrd = rigaOrd;
return this;
}
public BigDecimal getQtaCol() {
return qtaCol;
}
public HistoryVersamentoProdULDTO.OrdineDto setQtaCol(BigDecimal qtaCol) {
this.qtaCol = qtaCol;
return this;
}
public BigDecimal getNumCnf() {
return numCnf;
}
public HistoryVersamentoProdULDTO.OrdineDto setNumCnf(BigDecimal numCnf) {
this.numCnf = numCnf;
return this;
}
public Integer getPercentageHr() {
return percentageHr;
}
public OrdineDto setPercentageHr(Integer percentageHr) {
this.percentageHr = percentageHr;
return this;
}
}
}

View File

@ -1,10 +1,12 @@
package it.integry.integrywmsnative.gest.prod_recupero_materiale.dto; package it.integry.integrywmsnative.gest.prod_recupero_materiale.dto;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import it.integry.integrywmsnative.core.model.MtbAart; import it.integry.integrywmsnative.core.model.MtbAart;
import it.integry.integrywmsnative.core.utility.UtilityDate;
public class HistoryVersamentoProdUL { public class HistoryVersamentoProdULRestDTO {
private String gestione; private String gestione;
@ -29,13 +31,26 @@ public class HistoryVersamentoProdUL {
private String serColloRif; private String serColloRif;
private Integer numColloRif; private Integer numColloRif;
private MtbAart mtbAart; private Integer numOrd;
private String dataOrd;
private String gestioneOrd;
private Integer rigaOrd;
private Integer percentageHr;
public Integer getPercentageHr() {
return percentageHr;
}
public HistoryVersamentoProdULRestDTO setPercentageHr(Integer percentageHr) {
this.percentageHr = percentageHr;
return this;
}
public String getGestione() { public String getGestione() {
return gestione; return gestione;
} }
public HistoryVersamentoProdUL setGestione(String gestione) { public HistoryVersamentoProdULRestDTO setGestione(String gestione) {
this.gestione = gestione; this.gestione = gestione;
return this; return this;
} }
@ -44,7 +59,7 @@ public class HistoryVersamentoProdUL {
return dataCollo; return dataCollo;
} }
public HistoryVersamentoProdUL setDataCollo(String dataCollo) { public HistoryVersamentoProdULRestDTO setDataCollo(String dataCollo) {
this.dataCollo = dataCollo; this.dataCollo = dataCollo;
return this; return this;
} }
@ -53,7 +68,7 @@ public class HistoryVersamentoProdUL {
return serCollo; return serCollo;
} }
public HistoryVersamentoProdUL setSerCollo(String serCollo) { public HistoryVersamentoProdULRestDTO setSerCollo(String serCollo) {
this.serCollo = serCollo; this.serCollo = serCollo;
return this; return this;
} }
@ -62,7 +77,7 @@ public class HistoryVersamentoProdUL {
return numCollo; return numCollo;
} }
public HistoryVersamentoProdUL setNumCollo(Integer numCollo) { public HistoryVersamentoProdULRestDTO setNumCollo(Integer numCollo) {
this.numCollo = numCollo; this.numCollo = numCollo;
return this; return this;
} }
@ -71,7 +86,7 @@ public class HistoryVersamentoProdUL {
return segno; return segno;
} }
public HistoryVersamentoProdUL setSegno(String segno) { public HistoryVersamentoProdULRestDTO setSegno(String segno) {
this.segno = segno; this.segno = segno;
return this; return this;
} }
@ -80,7 +95,7 @@ public class HistoryVersamentoProdUL {
return codMart; return codMart;
} }
public HistoryVersamentoProdUL setCodMart(String codMart) { public HistoryVersamentoProdULRestDTO setCodMart(String codMart) {
this.codMart = codMart; this.codMart = codMart;
return this; return this;
} }
@ -89,7 +104,7 @@ public class HistoryVersamentoProdUL {
return codCol; return codCol;
} }
public HistoryVersamentoProdUL setCodCol(String codCol) { public HistoryVersamentoProdULRestDTO setCodCol(String codCol) {
this.codCol = codCol; this.codCol = codCol;
return this; return this;
} }
@ -98,7 +113,7 @@ public class HistoryVersamentoProdUL {
return codTagl; return codTagl;
} }
public HistoryVersamentoProdUL setCodTagl(String codTagl) { public HistoryVersamentoProdULRestDTO setCodTagl(String codTagl) {
this.codTagl = codTagl; this.codTagl = codTagl;
return this; return this;
} }
@ -107,7 +122,7 @@ public class HistoryVersamentoProdUL {
return codJfas; return codJfas;
} }
public HistoryVersamentoProdUL setCodJfas(String codJfas) { public HistoryVersamentoProdULRestDTO setCodJfas(String codJfas) {
this.codJfas = codJfas; this.codJfas = codJfas;
return this; return this;
} }
@ -116,7 +131,7 @@ public class HistoryVersamentoProdUL {
return descrizioneFase; return descrizioneFase;
} }
public HistoryVersamentoProdUL setDescrizioneFase(String descrizioneFase) { public HistoryVersamentoProdULRestDTO setDescrizioneFase(String descrizioneFase) {
this.descrizioneFase = descrizioneFase; this.descrizioneFase = descrizioneFase;
return this; return this;
} }
@ -125,7 +140,7 @@ public class HistoryVersamentoProdUL {
return qtaCol; return qtaCol;
} }
public HistoryVersamentoProdUL setQtaCol(BigDecimal qtaCol) { public HistoryVersamentoProdULRestDTO setQtaCol(BigDecimal qtaCol) {
this.qtaCol = qtaCol; this.qtaCol = qtaCol;
return this; return this;
} }
@ -134,7 +149,7 @@ public class HistoryVersamentoProdUL {
return numCnf; return numCnf;
} }
public HistoryVersamentoProdUL setNumCnf(BigDecimal numCnf) { public HistoryVersamentoProdULRestDTO setNumCnf(BigDecimal numCnf) {
this.numCnf = numCnf; this.numCnf = numCnf;
return this; return this;
} }
@ -143,7 +158,7 @@ public class HistoryVersamentoProdUL {
return partitaMag; return partitaMag;
} }
public HistoryVersamentoProdUL setPartitaMag(String partitaMag) { public HistoryVersamentoProdULRestDTO setPartitaMag(String partitaMag) {
this.partitaMag = partitaMag; this.partitaMag = partitaMag;
return this; return this;
} }
@ -152,7 +167,7 @@ public class HistoryVersamentoProdUL {
return codJcom; return codJcom;
} }
public HistoryVersamentoProdUL setCodJcom(String codJcom) { public HistoryVersamentoProdULRestDTO setCodJcom(String codJcom) {
this.codJcom = codJcom; this.codJcom = codJcom;
return this; return this;
} }
@ -161,7 +176,7 @@ public class HistoryVersamentoProdUL {
return datetimeRow; return datetimeRow;
} }
public HistoryVersamentoProdUL setDatetimeRow(String datetimeRow) { public HistoryVersamentoProdULRestDTO setDatetimeRow(String datetimeRow) {
this.datetimeRow = datetimeRow; this.datetimeRow = datetimeRow;
return this; return this;
} }
@ -170,7 +185,7 @@ public class HistoryVersamentoProdUL {
return descrizioneArt; return descrizioneArt;
} }
public HistoryVersamentoProdUL setDescrizioneArt(String descrizioneArt) { public HistoryVersamentoProdULRestDTO setDescrizioneArt(String descrizioneArt) {
this.descrizioneArt = descrizioneArt; this.descrizioneArt = descrizioneArt;
return this; return this;
} }
@ -179,7 +194,7 @@ public class HistoryVersamentoProdUL {
return untMis; return untMis;
} }
public HistoryVersamentoProdUL setUntMis(String untMis) { public HistoryVersamentoProdULRestDTO setUntMis(String untMis) {
this.untMis = untMis; this.untMis = untMis;
return this; return this;
} }
@ -188,7 +203,7 @@ public class HistoryVersamentoProdUL {
return gestioneRif; return gestioneRif;
} }
public HistoryVersamentoProdUL setGestioneRif(String gestioneRif) { public HistoryVersamentoProdULRestDTO setGestioneRif(String gestioneRif) {
this.gestioneRif = gestioneRif; this.gestioneRif = gestioneRif;
return this; return this;
} }
@ -197,7 +212,7 @@ public class HistoryVersamentoProdUL {
return dataColloRif; return dataColloRif;
} }
public HistoryVersamentoProdUL setDataColloRif(String dataColloRif) { public HistoryVersamentoProdULRestDTO setDataColloRif(String dataColloRif) {
this.dataColloRif = dataColloRif; this.dataColloRif = dataColloRif;
return this; return this;
} }
@ -206,7 +221,7 @@ public class HistoryVersamentoProdUL {
return serColloRif; return serColloRif;
} }
public HistoryVersamentoProdUL setSerColloRif(String serColloRif) { public HistoryVersamentoProdULRestDTO setSerColloRif(String serColloRif) {
this.serColloRif = serColloRif; this.serColloRif = serColloRif;
return this; return this;
} }
@ -215,17 +230,48 @@ public class HistoryVersamentoProdUL {
return numColloRif; return numColloRif;
} }
public HistoryVersamentoProdUL setNumColloRif(Integer numColloRif) { public HistoryVersamentoProdULRestDTO setNumColloRif(Integer numColloRif) {
this.numColloRif = numColloRif; this.numColloRif = numColloRif;
return this; return this;
} }
public MtbAart getMtbAart() { public Integer getNumOrd() {
return mtbAart; return numOrd;
} }
public HistoryVersamentoProdUL setMtbAart(MtbAart mtbAart) { public HistoryVersamentoProdULRestDTO setNumOrd(Integer numOrd) {
this.mtbAart = mtbAart; this.numOrd = numOrd;
return this;
}
public Date getDataOrdD() {
return UtilityDate.recognizeDateWithExceptionHandler(getDataOrdS());
}
public String getDataOrdS() {
return dataOrd;
}
public HistoryVersamentoProdULRestDTO setDataOrd(String dataOrd) {
this.dataOrd = dataOrd;
return this;
}
public Integer getRigaOrd() {
return rigaOrd;
}
public HistoryVersamentoProdULRestDTO setRigaOrd(Integer rigaOrd) {
this.rigaOrd = rigaOrd;
return this;
}
public String getGestioneOrd() {
return gestioneOrd;
}
public HistoryVersamentoProdULRestDTO setGestioneOrd(String gestioneOrd) {
this.gestioneOrd = gestioneOrd;
return this; return this;
} }
} }

View File

@ -13,6 +13,7 @@ import com.annimon.stream.Stream;
import com.tfb.fbtoast.FBToast; import com.tfb.fbtoast.FBToast;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -36,7 +37,8 @@ import it.integry.integrywmsnative.core.utility.UtilityString;
import it.integry.integrywmsnative.databinding.FragmentProdRecuperoMaterialeBinding; import it.integry.integrywmsnative.databinding.FragmentProdRecuperoMaterialeBinding;
import it.integry.integrywmsnative.gest.prod_recupero_materiale.core.HistoryULsListAdapter; import it.integry.integrywmsnative.gest.prod_recupero_materiale.core.HistoryULsListAdapter;
import it.integry.integrywmsnative.gest.prod_recupero_materiale.core.ProdRecuperoMaterialeHelper; import it.integry.integrywmsnative.gest.prod_recupero_materiale.core.ProdRecuperoMaterialeHelper;
import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdUL; import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdULDTO;
import it.integry.integrywmsnative.gest.prod_recupero_materiale.dto.HistoryVersamentoProdULRestDTO;
import it.integry.integrywmsnative.view.dialogs.DialogCommon; import it.integry.integrywmsnative.view.dialogs.DialogCommon;
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageHelper; import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageHelper;
import it.integry.integrywmsnative.view.dialogs.input_quantity.DialogInputQuantity; import it.integry.integrywmsnative.view.dialogs.input_quantity.DialogInputQuantity;
@ -53,7 +55,7 @@ public class ProdRecuperoMaterialeViewModel {
private HistoryULsListAdapter mAdapter; private HistoryULsListAdapter mAdapter;
private List<HistoryVersamentoProdUL> mDataset; private List<HistoryVersamentoProdULDTO> mDataset;
public ObservableField<MtbColt> mtbColt = new ObservableField<>(); public ObservableField<MtbColt> mtbColt = new ObservableField<>();
@ -112,9 +114,9 @@ public class ProdRecuperoMaterialeViewModel {
if(mtbColt != null) { if(mtbColt != null) {
HistoryVersamentoProdUL historyVersamentoProdUL = this.getHistoryElementFromMtbColt(mtbColt); HistoryVersamentoProdULDTO historyVersamentoProdULRestDTO = this.getHistoryElementFromMtbColt(mtbColt);
if(historyVersamentoProdUL != null) { if(historyVersamentoProdULRestDTO != null) {
this.dispatchItem(historyVersamentoProdUL, mtbColt, progressDialog); this.dispatchItem(historyVersamentoProdULRestDTO, mtbColt, progressDialog);
} else { } else {
DialogCommon.showNoULFound(mContext, () -> { DialogCommon.showNoULFound(mContext, () -> {
BarcodeManager.enable(); BarcodeManager.enable();
@ -136,8 +138,8 @@ public class ProdRecuperoMaterialeViewModel {
} }
private HistoryVersamentoProdUL getHistoryElementFromMtbColt(MtbColt mtbColt) { private HistoryVersamentoProdULDTO getHistoryElementFromMtbColt(MtbColt mtbColt) {
List<HistoryVersamentoProdUL> filteredItems = Stream.of(mDataset) List<HistoryVersamentoProdULDTO> filteredItems = Stream.of(mDataset)
.filter(x -> Objects.equals(x.getNumColloRif(), mtbColt.getNumCollo()) && .filter(x -> Objects.equals(x.getNumColloRif(), mtbColt.getNumCollo()) &&
x.getDataColloRif().equals(mtbColt.getDataColloS()) && x.getDataColloRif().equals(mtbColt.getDataColloS()) &&
x.getSerColloRif().equalsIgnoreCase(mtbColt.getSerCollo()) && x.getSerColloRif().equalsIgnoreCase(mtbColt.getSerCollo()) &&
@ -152,7 +154,7 @@ public class ProdRecuperoMaterialeViewModel {
} }
private void dispatchItem(HistoryVersamentoProdUL item, MtbColt sourceMtbColt, Dialog dialogProgress) { private void dispatchItem(HistoryVersamentoProdULDTO item, MtbColt sourceMtbColt, Dialog dialogProgress) {
BigDecimal qtaDaEvadere = BigDecimal.ZERO; BigDecimal qtaDaEvadere = BigDecimal.ZERO;
qtaDaEvadere = qtaDaEvadere.add(item.getQtaCol()); qtaDaEvadere = qtaDaEvadere.add(item.getQtaCol());
@ -164,7 +166,9 @@ public class ProdRecuperoMaterialeViewModel {
.setQtaOrd(null) .setQtaOrd(null)
.setMtbAart(item.getMtbAart()) .setMtbAart(item.getMtbAart())
.setCanPartitaMagBeChanged(false) .setCanPartitaMagBeChanged(false)
.setQtaTot(BigDecimal.ONE) .setNumCnf(1)
.setQtaCnf(item.getQtaCnf())
.setQtaTot(item.getQtaCnf())
.setMaxQta(qtaDaEvadere) .setMaxQta(qtaDaEvadere)
.setQtaDisponibile(qtaDaEvadere); .setQtaDisponibile(qtaDaEvadere);
@ -179,7 +183,7 @@ public class ProdRecuperoMaterialeViewModel {
private void onItemDispatched(HistoryVersamentoProdUL item, BigDecimal quantity, MtbColt sourceMtbColt, Dialog progress) { private void onItemDispatched(HistoryVersamentoProdULDTO item, BigDecimal quantity, MtbColt sourceMtbColt, Dialog progress) {
if(progress == null) { if(progress == null) {
progress = UtilityProgress.createDefaultProgressDialog(mContext); progress = UtilityProgress.createDefaultProgressDialog(mContext);
@ -193,20 +197,31 @@ public class ProdRecuperoMaterialeViewModel {
.setGestione(item.getGestione()) .setGestione(item.getGestione())
.setMtbColr(new ObservableArrayList<>()); .setMtbColr(new ObservableArrayList<>());
final MtbColr mtbColrScarico = new MtbColr() for(HistoryVersamentoProdULDTO.OrdineDto ordine : item.getOrdini()) {
.setCodMart(item.getCodMart()) BigDecimal qtaCol = quantity.multiply(new BigDecimal(-1).multiply(new BigDecimal(ordine.getPercentageHr()))).divide(new BigDecimal(100), 3, RoundingMode.HALF_EVEN);
.setPartitaMag(UtilityString.empty2null(item.getPartitaMag()))
.setQtaCol(quantity.multiply(new BigDecimal(-1))) final MtbColr mtbColrScarico = new MtbColr()
.setDescrizione(UtilityString.isNullOrEmpty(item.getMtbAart().getDescrizioneEstesa()) ? item.getMtbAart().getDescrizione() : item.getMtbAart().getDescrizioneEstesa()) .setCodMart(item.getCodMart())
.setDatetimeRow(UtilityDate.getDateInstance()) .setPartitaMag(UtilityString.empty2null(item.getPartitaMag()))
.setNumColloRif(item.getNumColloRif()) .setQtaCol(qtaCol)
.setDataColloRif(item.getDataColloRif()) .setQtaCnf(ordine.getQtaCnf())
.setGestioneRif(item.getGestioneRif()) .setDescrizione(UtilityString.isNullOrEmpty(item.getMtbAart().getDescrizioneEstesa()) ? item.getMtbAart().getDescrizione() : item.getMtbAart().getDescrizioneEstesa())
.setSerColloRif(item.getSerColloRif()); .setDatetimeRow(UtilityDate.getDateInstance())
.setNumColloRif(item.getNumColloRif())
.setDataColloRif(item.getDataColloRif())
.setGestioneRif(item.getGestioneRif())
.setSerColloRif(item.getSerColloRif())
.setDataOrd(ordine.getData())
.setNumOrd(ordine.getNumero())
.setRigaOrd(ordine.getRigaOrd());
mtbColrScarico.setOperation(CommonModelConsts.OPERATION.INSERT);
mtbColtScarico.getMtbColr().add(mtbColrScarico);
}
mtbColrScarico.setOperation(CommonModelConsts.OPERATION.INSERT);
mtbColtScarico.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE); mtbColtScarico.setOperation(CommonModelConsts.OPERATION.INSERT_OR_UPDATE);
mtbColtScarico.getMtbColr().add(mtbColrScarico);
RunnableArgs<MtbColt> saveRunnable = mtbColt -> { RunnableArgs<MtbColt> saveRunnable = mtbColt -> {