From 56d84a2a86ec7c61cd75445c12a3d5eee239723c Mon Sep 17 00:00:00 2001 From: Enrique Blasco Date: Tue, 23 Jun 2020 11:58:02 +0200 Subject: [PATCH] collections v2 --- app/build.gradle | 1 + .../java/es/verdnatura/domain/ApiUtils.kt | 2 +- .../es/verdnatura/domain/ConstAndValues.kt | 8 + .../java/es/verdnatura/domain/Extensions.kt | 2 +- .../domain/GetSacadorControladorUserCase.kt | 52 +- .../es/verdnatura/domain/VerdnaturaService.kt | 57 ++ .../presentation/common/UICallbacks.kt | 2 +- .../presentation/common/UIExtensions.kt | 12 + .../view/component/CustomDialogList.kt | 24 + .../view/feature/collection/CollectionVO.kt | 10 + .../collection/adapter/PlacementAdapter.kt | 36 ++ .../feature/collection/adapter/SaleAdapter.kt | 84 +++ .../collection/fragment/CollectionFragment.kt | 547 +++++++++++++++++- .../fragment/CollectionViewModel.kt | 127 +++- .../collection/mapper/CollectionMapper.kt | 37 ++ .../feature/main/activity/MainActivity.kt | 4 +- .../sacador/adapter/CollectionAdapter.kt | 3 +- .../sacador/fragment/SacadorFragment.kt | 5 +- .../feature/sacador/model/TicketItemVO.kt | 21 + .../drawable/ic_playlist_add_black_24dp.xml | 5 + app/src/main/res/drawable/ic_visibility.xml | 5 + .../layout/component_custom_list_dialog.xml | 22 + .../main/res/layout/fragment_collection.xml | 46 +- app/src/main/res/layout/fragment_sacador.xml | 4 +- app/src/main/res/layout/item_article_row.xml | 227 +++++++- .../main/res/layout/item_placement_row.xml | 68 +++ app/src/main/res/values/dimens.xml | 5 +- 27 files changed, 1371 insertions(+), 45 deletions(-) create mode 100644 app/src/main/java/es/verdnatura/domain/ConstAndValues.kt create mode 100644 app/src/main/java/es/verdnatura/presentation/view/feature/collection/CollectionVO.kt create mode 100644 app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/PlacementAdapter.kt create mode 100644 app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/SaleAdapter.kt create mode 100644 app/src/main/java/es/verdnatura/presentation/view/feature/collection/mapper/CollectionMapper.kt create mode 100644 app/src/main/res/drawable/ic_playlist_add_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_visibility.xml create mode 100644 app/src/main/res/layout/item_placement_row.xml diff --git a/app/build.gradle b/app/build.gradle index b0d9f5fc..79a50907 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -57,6 +57,7 @@ dependencies { implementation 'com.squareup.retrofit2:converter-gson:2.0.2' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' implementation "com.airbnb.android:lottie:$lottieVersion" + implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0' // Architecture components diff --git a/app/src/main/java/es/verdnatura/domain/ApiUtils.kt b/app/src/main/java/es/verdnatura/domain/ApiUtils.kt index b17cfbb4..6aa08224 100644 --- a/app/src/main/java/es/verdnatura/domain/ApiUtils.kt +++ b/app/src/main/java/es/verdnatura/domain/ApiUtils.kt @@ -8,7 +8,7 @@ import java.util.concurrent.TimeUnit class ApiUtils { companion object { - const val BASE_URL:String = "http://192.168.1.108:8008/" + const val BASE_URL:String = "http://192.168.1.107:8009/" //const val BASE_URL:String = "https://app.verdnatura.es/" fun getApiService():VerdnaturaService{ val retrofit = Retrofit.Builder() diff --git a/app/src/main/java/es/verdnatura/domain/ConstAndValues.kt b/app/src/main/java/es/verdnatura/domain/ConstAndValues.kt new file mode 100644 index 00000000..79e6822a --- /dev/null +++ b/app/src/main/java/es/verdnatura/domain/ConstAndValues.kt @@ -0,0 +1,8 @@ +package es.verdnatura.domain + +object ConstAndValues { + const val SACADOR = 14 + const val CONTROLADOR = 8 + const val OK = 3 +} + diff --git a/app/src/main/java/es/verdnatura/domain/Extensions.kt b/app/src/main/java/es/verdnatura/domain/Extensions.kt index 7281e0f1..f2e18a59 100644 --- a/app/src/main/java/es/verdnatura/domain/Extensions.kt +++ b/app/src/main/java/es/verdnatura/domain/Extensions.kt @@ -3,7 +3,7 @@ package es.verdnatura.domain import android.content.Context import android.widget.Toast -fun Any.toast(context: Context, duration: Int = Toast.LENGTH_SHORT): Toast { +fun Any.toast(context: Context?, duration: Int = Toast.LENGTH_SHORT): Toast { return Toast.makeText(context, this.toString(), duration).apply { show() } } diff --git a/app/src/main/java/es/verdnatura/domain/GetSacadorControladorUserCase.kt b/app/src/main/java/es/verdnatura/domain/GetSacadorControladorUserCase.kt index 49211622..4646f9e2 100644 --- a/app/src/main/java/es/verdnatura/domain/GetSacadorControladorUserCase.kt +++ b/app/src/main/java/es/verdnatura/domain/GetSacadorControladorUserCase.kt @@ -1,6 +1,8 @@ package es.verdnatura.domain +import es.verdnatura.presentation.view.feature.collection.ItemVO import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO +import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO import retrofit2.Call class GetSacadorControladorUserCase : RestClient() { @@ -17,4 +19,52 @@ class GetSacadorControladorUserCase : RestClient() { return restClient!!.collectionGet("json","1",usuario,password,"application/json") } -} \ No newline at end of file + fun saleTrackingReplace(usuario:String,password:String,saleFk:String,vOriginalQuantity:String,vStateFk:String,vIsChecked:String) : Call { + val params:ArrayList = ArrayList(); + params.add(saleFk) + params.add(vOriginalQuantity) + params.add(vStateFk) + params.add(vIsChecked) + return restClient!!.saleTrackingReplace("json","1",usuario,password,"application/json",params) + } + + fun itemPlacementSupplyAiming(usuario:String,password:String,shelvingFk:String,quantity:String,itemFk:String) : Call> { + val params:ArrayList = ArrayList(); + params.add(shelvingFk) + params.add(quantity) + params.add(itemFk) + return restClient!!.itemPlacementSupplyAiming("json","1",usuario,password,"application/json",params) + } + + fun itemShelvingSaleSupplyAdd(usuario:String,password:String,itemShelvingFk:String,saleFk:String,quantity:String) : Call { + val params:ArrayList = ArrayList(); + params.add(itemShelvingFk) + params.add(saleFk) + params.add(quantity) + return restClient!!.itemShelvingSaleSupplyAdd("json","1",usuario,password,"application/json",params) + } + + fun collectionStickerPrint(usuario:String,password:String,collectionFk: String,sectorFk: String) : Call { + val params:ArrayList = ArrayList() + params.add(collectionFk) + params.add(sectorFk) + return restClient!!.collectionStickerPrint("json","1",usuario,password,"application/json",params) + } + + fun itemGetAvailable(usuario:String,password:String,itemFk: String,warehouseFk: String) : Call { + val params:ArrayList = ArrayList() + params.add(itemFk) + params.add(warehouseFk) + return restClient!!.itemGetAvailable("json","1",usuario,password,"application/json",params) + } + + fun collectionAddItem(usuario:String,password:String,itemFk: String,quantityFk: String,ticketFk: String,warehouseFk: String) : Call { + val params:ArrayList = ArrayList() + params.add(itemFk) + params.add(quantityFk) + params.add(ticketFk) + params.add(warehouseFk) + return restClient!!.collectionAddItem("json","1",usuario,password,"application/json",params) + } + +} diff --git a/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt b/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt index f57838cc..edba7974 100644 --- a/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt +++ b/app/src/main/java/es/verdnatura/domain/VerdnaturaService.kt @@ -5,11 +5,14 @@ package es.verdnatura.domain import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO +import es.verdnatura.presentation.view.feature.collection.ItemVO import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO import es.verdnatura.presentation.view.feature.historico.model.ItemHistoricoVO import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO import es.verdnatura.presentation.view.feature.paletizador.model.* import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO +import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO +import es.verdnatura.presentation.view.feature.sacador.model.PlacementVO import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO import retrofit2.Call @@ -69,6 +72,60 @@ interface VerdnaturaService { @Body params: List): Call + @POST("almacennew/saleTrackingReplace") + fun saleTrackingReplace(@Header("aplicacion") aplicacion: String, + @Header("version") version: String, + @Header("user") user: String, + @Header("pass") pass: String, + @Header("Content-Type") content_type: String, + @Body params: List): + Call + + @POST("almacennew/itemPlacementSupplyAiming") + fun itemPlacementSupplyAiming(@Header("aplicacion") aplicacion: String, + @Header("version") version: String, + @Header("user") user: String, + @Header("pass") pass: String, + @Header("Content-Type") content_type: String, + @Body params: List): + Call> + + @POST("almacennew/itemShelvingSaleSupplyAdd") + fun itemShelvingSaleSupplyAdd(@Header("aplicacion") aplicacion: String, + @Header("version") version: String, + @Header("user") user: String, + @Header("pass") pass: String, + @Header("Content-Type") content_type: String, + @Body params: List): + Call + + @POST("almacennew/collectionStickerPrint") + fun collectionStickerPrint(@Header("aplicacion") aplicacion: String, + @Header("version") version: String, + @Header("user") user: String, + @Header("pass") pass: String, + @Header("Content-Type") content_type: String, + @Body params: List): + Call + + @POST("almacennew/itemGetAvailable") + fun itemGetAvailable(@Header("aplicacion") aplicacion: String, + @Header("version") version: String, + @Header("user") user: String, + @Header("pass") pass: String, + @Header("Content-Type") content_type: String, + @Body params: List): + Call + + @POST("almacennew/collectionAddItem") + fun collectionAddItem(@Header("aplicacion") aplicacion: String, + @Header("version") version: String, + @Header("user") user: String, + @Header("pass") pass: String, + @Header("Content-Type") content_type: String, + @Body params: List): + Call + //PASILLEROS ========================================================================> //CONSULTAR ARTICULO ========================================================================> diff --git a/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt b/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt index 8379322b..01761a56 100644 --- a/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt +++ b/app/src/main/java/es/verdnatura/presentation/common/UICallbacks.kt @@ -81,5 +81,5 @@ interface OnScanLongClickListener { } interface OnCollectionSelectedListener { - fun onCollectionSelected(collection: CollectionVO) + fun onCollectionSelected(collection: CollectionVO,type:Int) } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/common/UIExtensions.kt b/app/src/main/java/es/verdnatura/presentation/common/UIExtensions.kt index 5834443f..4afc77e0 100644 --- a/app/src/main/java/es/verdnatura/presentation/common/UIExtensions.kt +++ b/app/src/main/java/es/verdnatura/presentation/common/UIExtensions.kt @@ -7,11 +7,13 @@ import android.graphics.drawable.Drawable import android.os.Bundle import android.view.View import android.view.ViewGroup +import android.view.ViewTreeObserver import android.widget.ImageView import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentTransaction +import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide import com.bumptech.glide.request.target.CustomTarget import com.bumptech.glide.request.transition.Transition @@ -113,4 +115,14 @@ fun Calendar.convertToDateString(): String { } return dayOfWeek + " " + day + " " + dayOfMonth +} + +fun RecyclerView.addViewObserver(function: () -> Unit) { + val view = this + view.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener { + override fun onGlobalLayout() { + view.viewTreeObserver.removeOnGlobalLayoutListener(this) + function.invoke() + } + }) } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogList.kt b/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogList.kt index 7db84dd2..b590aa13 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogList.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/component/CustomDialogList.kt @@ -23,6 +23,10 @@ class CustomDialogList (context: Context) : Dialog(context, R.style.DialogTheme) return custom_dialog_value } + fun getEditTextTwo() : TextInputEditText { + return custom_dialog_value_two + } + fun getValue() : String { return custom_dialog_value.text.toString() } @@ -33,6 +37,16 @@ class CustomDialogList (context: Context) : Dialog(context, R.style.DialogTheme) return this } + fun getValueTwo() : String { + return custom_dialog_value_two.text.toString() + } + + fun setValueTwo(value : String): CustomDialogList{ + custom_dialog_value_two.setText(value) + custom_dialog_value_two.visibility = View.VISIBLE + return this + } + fun setTitle(title: String): CustomDialogList { custom_dialog_title.visibility = View.VISIBLE custom_dialog_title.text = title @@ -54,4 +68,14 @@ class CustomDialogList (context: Context) : Dialog(context, R.style.DialogTheme) return this } + fun setHintValue(text:String): CustomDialogList{ + custom_dialog_value.hint = text + return this + } + + fun setHintValueTwo(text:String): CustomDialogList{ + custom_dialog_value_two.hint = text + return this + } + } \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/CollectionVO.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/CollectionVO.kt new file mode 100644 index 00000000..445d89bc --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/CollectionVO.kt @@ -0,0 +1,10 @@ +package es.verdnatura.presentation.view.feature.collection + +class ItemVO( + var id : String = "", + var longName : String = "", + var visible : String = "", + var available : String = "", + var isError: Boolean = false, + var errorMessage: String = "" +) \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/PlacementAdapter.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/PlacementAdapter.kt new file mode 100644 index 00000000..ccd636f0 --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/PlacementAdapter.kt @@ -0,0 +1,36 @@ +package es.verdnatura.presentation.view.feature.collection.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView +import es.verdnatura.databinding.ItemPlacementRowBinding +import es.verdnatura.presentation.view.feature.sacador.model.PlacementVO + +class PlacementAdapter ( + private val items: List +): RecyclerView.Adapter () { + var context: Context? = null + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AjustesItemHolder { + this.context = parent.context + return AjustesItemHolder( + ItemPlacementRowBinding.inflate(LayoutInflater.from(parent.context),parent,false) + ) + } + + override fun getItemCount() =items.size + + override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) { + holder.bind(items[position]) + } + + inner class AjustesItemHolder( + val binding: ItemPlacementRowBinding + ) : RecyclerView.ViewHolder(binding.root){ + fun bind(placement: PlacementVO) { + binding.apply { + this.item = placement + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/SaleAdapter.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/SaleAdapter.kt new file mode 100644 index 00000000..b4a6d889 --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/adapter/SaleAdapter.kt @@ -0,0 +1,84 @@ +package es.verdnatura.presentation.view.feature.collection.adapter + +import android.content.Context +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.core.content.ContextCompat +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView +import es.verdnatura.R +import es.verdnatura.databinding.ItemArticleRowBinding +import es.verdnatura.presentation.common.OnPasillerosItemClickListener +import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO +import es.verdnatura.presentation.view.feature.sacador.model.SaleVO + +class SaleAdapter ( + private val items: List, + private val onPasillerosItemClickListener: OnPasillerosItemClickListener +): RecyclerView.Adapter () { + var context:Context? = null + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AjustesItemHolder { + this.context = parent.context + return AjustesItemHolder( + ItemArticleRowBinding.inflate(LayoutInflater.from(parent.context),parent,false) + ) + } + + override fun getItemCount() =items.size + + override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) { + holder.bind(items[position]) + } + + inner class AjustesItemHolder( + val binding: ItemArticleRowBinding + ) : RecyclerView.ViewHolder(binding.root){ + fun bind(sale: SaleVO) { + binding.apply { + if (sale.startQuantity.isNullOrEmpty()) + sale.startQuantity = "0" + this.sale = sale + + val childLayoutManager = LinearLayoutManager(context!!, RecyclerView.HORIZONTAL, false) + itemArticlePlacements.apply { + layoutManager = childLayoutManager + adapter = PlacementAdapter(sale.placements) + } + + itemArticleItemFk.setOnClickListener { + onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Consultar artículo"),sale.itemFk) + } + + + if (sale.isPreviousPrepared == "1"){ + itemArticleRowSemaforoPre.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_dark_sky_blue)) + }else{ + itemArticleRowSemaforoPre.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_warm_grey)) + } + + if (sale.isPrepared == "1"){ + itemArticleRowSemaforoSac.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_pumpkin_orange)) + }else{ + itemArticleRowSemaforoSac.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_warm_grey)) + } + + if (sale.isControlled == "1"){ + itemArticleRowSemaforoCon.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_dark_mint)) + }else{ + itemArticleRowSemaforoCon.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_warm_grey)) + } + + if (sale.isControlled == "1"){ + contentLayout.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_dark_mint)) + }else if (sale.isPrepared == "1"){ + contentLayout.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_pumpkin_orange)) + }else if (sale.isPreviousPrepared == "1"){ + contentLayout.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_dark_sky_blue)) + }else{ + contentLayout.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_black)) + } + + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt index 27760c2f..49140653 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionFragment.kt @@ -3,42 +3,74 @@ package es.verdnatura.presentation.view.feature.collection.fragment import android.content.Context import android.content.SharedPreferences import android.graphics.drawable.Drawable -import androidx.lifecycle.ViewModelProviders +import android.media.MediaPlayer import android.os.Bundle -import android.util.Log -import androidx.fragment.app.Fragment -import android.view.LayoutInflater import android.view.View -import android.view.ViewGroup +import android.view.inputmethod.EditorInfo +import android.widget.Toast import androidx.lifecycle.Observer import androidx.recyclerview.widget.LinearLayoutManager - import es.verdnatura.R import es.verdnatura.databinding.FragmentCollectionBinding +import es.verdnatura.domain.ConstAndValues.CONTROLADOR +import es.verdnatura.domain.ConstAndValues.OK +import es.verdnatura.domain.ConstAndValues.SACADOR +import es.verdnatura.domain.toast import es.verdnatura.presentation.base.BaseFragment +import es.verdnatura.presentation.common.OnBarcodeRowClickListener import es.verdnatura.presentation.common.OnOptionsSelectedListener +import es.verdnatura.presentation.common.OnPasillerosItemClickListener +import es.verdnatura.presentation.common.addViewObserver +import es.verdnatura.presentation.view.component.CustomDialog +import es.verdnatura.presentation.view.component.CustomDialogInput +import es.verdnatura.presentation.view.component.CustomDialogList +import es.verdnatura.presentation.view.feature.articulo.adapter.BarcodeAdapter +import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO +import es.verdnatura.presentation.view.feature.collection.ItemVO +import es.verdnatura.presentation.view.feature.collection.adapter.SaleAdapter import es.verdnatura.presentation.view.feature.inventario.adapter.ToolBarAdapter +import es.verdnatura.presentation.view.feature.main.activity.MainActivity import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO +import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyListVO +import es.verdnatura.presentation.view.feature.sacador.model.SaleVO import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.fragment_collection.* +import kotlinx.android.synthetic.main.fragment_collection.splash_progress import kotlinx.android.synthetic.main.toolbar.* class CollectionFragment( - var collection : CollectionVO = CollectionVO() + var collection : CollectionVO = CollectionVO(), + var type:Int = SACADOR ) : BaseFragment(CollectionViewModel::class){ private var user = "" private var password = "" private var sectorFk = "" private var warehouseFk = "" + private var sales:List = listOf() + private var saleAdapter:SaleAdapter? = null + private var lm : LinearLayoutManager? = null + private var storedPosition: Int = 0 + private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null + private lateinit var customDialogList: CustomDialogList + private var placementSupplyAdapter : BarcodeAdapter? = null + private var listPlacementSupply:ArrayList = ArrayList() + private var storedShelvingPosition:Int = 0 + private lateinit var customDialogInput: CustomDialogInput + private var ticketSelected:String = "" + private lateinit var customDialog: CustomDialog + private var goBack:Boolean = false + var mperror: MediaPlayer? = null + var mpok: MediaPlayer? = null companion object { - fun newInstance(collection:CollectionVO) = CollectionFragment(collection) + fun newInstance(collection:CollectionVO,type:Int) = CollectionFragment(collection,type) } override fun onAttach(context: Context) { + if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context super.onAttach(context) - } + override fun getLayoutId(): Int = R.layout.fragment_collection override fun onCreate(savedInstanceState: Bundle?) { @@ -47,6 +79,8 @@ class CollectionFragment( password = prefs.getString(PASSWORD,"").toString() sectorFk = prefs.getInt(SECTORFK,1).toString() warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString() + mperror = MediaPlayer.create((activity as MainActivity),R.raw.error) + mpok = MediaPlayer.create((activity as MainActivity),R.raw.ok) if (collection.tickets.isEmpty()){ viewModel.collectionTicketGet(user,password,collection.collectionFk,sectorFk) }else{ @@ -57,6 +91,9 @@ class CollectionFragment( } override fun init() { + customDialogList = CustomDialogList(requireContext()) + customDialogInput = CustomDialogInput(requireContext()) + customDialog = CustomDialog(requireContext()) activity!!.main_bottom_navigation.visibility = View.GONE splash_progress.visibility = View.VISIBLE toolbar_title.text = "collectionTicket_get" @@ -65,15 +102,29 @@ class CollectionFragment( super.init() } + override fun onPause() { + goBack = true + super.onPause() + } + private fun setToolBar(){ val listIcons:ArrayList = ArrayList() - val iconReload : Drawable = resources.getDrawable(R.drawable.ic_autorenew_black_24dp,resources.newTheme()) - listIcons.add(iconReload) + val iconPrint : Drawable = resources.getDrawable(R.drawable.ic_print_black_24dp,resources.newTheme()) + val iconSearch : Drawable = resources.getDrawable(R.drawable.ic_visibility,resources.newTheme()) + val iconAdd : Drawable = resources.getDrawable(R.drawable.ic_playlist_add_black_24dp,resources.newTheme()) + + listIcons.add(iconPrint) + listIcons.add(iconSearch) + listIcons.add(iconAdd) + toolbar_icons.adapter = ToolBarAdapter(listIcons,object: OnOptionsSelectedListener { override fun onOptionsItemSelected(item: Drawable) { - if (item == iconReload){ - splash_progress.visibility = View.VISIBLE - viewModel.collectionTicketGet(user,password,collection.collectionFk,sectorFk) + if (item == iconPrint){ + print() + }else if (item == iconSearch){ + showDisponibility() + }else if (item == iconAdd){ + addItem() } } }) @@ -84,6 +135,26 @@ class CollectionFragment( backButton.setOnClickListener { activity!!.onBackPressed() } + + scan_input.requestFocus() + scan_input.setOnEditorActionListener { v, actionId, event -> + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { + if (!scan_input.text.toString().isNullOrEmpty()){ + findSale(scan_input.text.toString()) + } + scan_input.setText("") + (activity as MainActivity).hideKeyboard(scan_input) + return@setOnEditorActionListener true + } + true + } + (activity as MainActivity).hideKeyboard(scan_input) + + collection_swipe.setOnRefreshListener { + splash_progress.visibility = View.VISIBLE + viewModel.collectionTicketGet(user,password,collection.collectionFk,sectorFk) + collection_swipe.isRefreshing = false + } } override fun observeViewModel() { @@ -100,13 +171,457 @@ class CollectionFragment( } }) + + placementSuppleyList.observe(viewLifecycleOwner, Observer { + splash_progress.visibility = View.GONE + printShelvingResult(it) + }) + + item.observe(viewLifecycleOwner, Observer { + splash_progress.visibility = View.GONE + if (!goBack) toastDisponibility(it) + goBack = false + }) + + responseNew.observe(viewLifecycleOwner, Observer { + splash_progress.visibility = View.GONE + if (!goBack){ + if (it.isError){ + customDialog.setTitle("Disponibilidad").setDescription(it.errorMessage).setKoButton("Cerrar"){ + customDialog.hide() + }.show() + }else{ + splash_progress.visibility = View.VISIBLE + viewModel.collectionTicketGet(user,password,collection.collectionFk,sectorFk) + } + } + + goBack = false + + + + }) + } } - + //CREATE LIST private fun createCollectionList(){ + toolbar_title.text = collection.collectionFk splash_progress.visibility = View.GONE - Log.i("Collection",collection.collectionFk) + var salesList:ArrayList = ArrayList() + collection.tickets.forEach { ticket -> + ticket.sales.forEach { + salesList.add(it) + } + } + + sales = salesList.sortedWith(compareBy({ it.saleOrder })) + saleAdapter = SaleAdapter(sales,pasillerosItemClickListener!!) + lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) + fragment_sacador_collections.adapter = saleAdapter + fragment_sacador_collections.layoutManager = lm + setTotalLines() + if (storedPosition != 0) + setListPosition(storedPosition) } + //SEARCH AND MARK + private fun findSale(txtscan:String){ + var index = 0 + var isBreak = false + var isOk = false + if (type == SACADOR){ + for (saleVO in sales) { + if(saleVO.startQuantity != saleVO.quantity){ + //1- Por itemFk + if (txtscan == saleVO.itemFk){ + mpok!!.start() + isOk = true + markLine(index,type) + break + } + //2- Por carro + var shelvingIndex = 0 + for (placementVO in saleVO.placements){ + if (txtscan.toUpperCase() == placementVO.shelving.toUpperCase()){ + mpok!!.start() + isOk = true + showShelving(index,shelvingIndex) + isBreak = true + break + } + shelvingIndex+=1 + } + if (isBreak) break + //3- Por barcode + saleVO.Barcodes.forEach { barcode -> + if (txtscan == barcode){ + mpok!!.start() + isOk = true + markLine(index,type) + isBreak = true + } + } + if (isBreak) break + } + index += 1 + } + if (!isOk) mperror!!.start() + }else if(type == CONTROLADOR){ + for (saleVO in sales) { + if(saleVO.isControlled == "0"){ + //1- Por itemFk + if (txtscan == saleVO.itemFk){ + markLine(index,type) + break + } + //2- Por barcode + saleVO.Barcodes.forEach { barcode -> + if (txtscan == barcode){ + markLine(index,type) + isBreak = true + } + } + if (isBreak) break + } + index += 1 + } + } + + } + + private fun markLine(position:Int,newType: Int){ + if (type == SACADOR){ + sales[position].isPrepared = if (sales[position].isPrepared == "1") "0" else "1" + if (sales[position].isPrepared == "1"){ + sales[position].startQuantity = sales[position].quantity + }else{ + sales[position].startQuantity = if(sales[position].startQuantity == sales[position].quantity) "0" else sales[position].startQuantity + } + }else if (type == CONTROLADOR) + sales[position].isControlled = if (sales[position].isControlled == "1") "0" else "1" + + saleAdapter!!.notifyDataSetChanged() + + setListPosition(position) + saleTrackingReplace(position,newType) + setTotalLines() + } + + private fun setListPosition(position:Int){ + storedPosition = position + fragment_sacador_collections.addViewObserver { + lm!!.scrollToPositionWithOffset(position,0) + } + } + + private fun saleTrackingReplace(position: Int,type: Int){ + viewModel.saleTrackingReplace( + usuario = user, + password = password, + saleFk = sales[position].saleFk, + vIsChecked = if (type == SACADOR) sales[position].isPrepared else sales[position].isControlled, + vOriginalQuantity = sales[position].startQuantity, + vStateFk = type.toString() + ) + } + + private fun setTotalLines(){ + var totalMark = 0 + sales.forEach { + if (type == SACADOR) + if (it.isPrepared == "1" || it.isControlled == "1" || it.isPreviousPrepared == "1") + totalMark += 1 + else if (type == CONTROLADOR) + if (it.isControlled == "1") + totalMark += 1 + } + toolbar_title.text = "" + totalMark + "/" + sales.size + if (totalMark == sales.size) "Colección completa".toast(this.context,Toast.LENGTH_SHORT) + } + + //SHELVINGS + private fun showShelving(position:Int,shelvingPosition:Int){ + storedShelvingPosition = shelvingPosition + storedPosition = position + splash_progress.visibility = View.VISIBLE + var quantityGet = "0" + try{ + quantityGet = (sales[position].quantity.toInt() - sales[position].startQuantity.toInt()).toString() + }catch (e:Exception){} + viewModel.itemPlacementSupplyAiming( + usuario = user, + password = password, + itemFk = sales[position].itemFk, + quantity = quantityGet, + shelvingFk = sales[position].placements[shelvingPosition].shelving + ) + } + + private fun printShelvingResult(placementSupplyListVO: PlacementSupplyListVO){ + var shelving = "" + var item = "" + var longName = "" + var total = "0" + var itemShelvingFk = "0" + if (!placementSupplyListVO.list.isEmpty()){ + val placement = placementSupplyListVO.list[0] + shelving = placement.shelving + item = placement.itemFk + longName = placement.longName + total = placement.total + itemShelvingFk = placement.itemShelvingFk + } + listPlacementSupply = ArrayList() + placementSupplyListVO.list.forEach { + listPlacementSupply.add(BarcodeVO(code = it.proposal)) + } + + customDialogList.setTitle(""+shelving+ "("+item+")"+" "+total+" de "+longName).setOkButton("Coger"){ + onQuantityOfShelvingSelected(itemShelvingFk) + customDialogList.hide() + + }.setKoButton("Cerrar"){ + customDialogList.hide() + }.setHintValue("Cantidad que coges:").setValue(total).show() + + + customDialogList.getEditText().requestFocus() + (activity as MainActivity).hideKeyboard(customDialogList.getEditText()) + + customDialogList.getEditText().setOnEditorActionListener { v, actionId, event -> + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { + if (!customDialogList.getValue().isNullOrEmpty()){ + onQuantityOfShelvingSelected(itemShelvingFk) + } + customDialogList.setValue("") + (activity as MainActivity).hideKeyboard(customDialogList.getEditText()) + return@setOnEditorActionListener true + customDialogList.hide() + } + false + } + + placementSupplyAdapter = BarcodeAdapter(listPlacementSupply,object: OnBarcodeRowClickListener { + override fun onBarcodeRowClickListener(item: BarcodeVO) { + placementSupplyListVO.list.forEach { + if (it.proposal == item.code){ + customDialogList.setValue(it.total) + total = it.total + itemShelvingFk = it.itemShelvingFk + } + } + + } + },showDelete = false) + customDialogList.getRecyclerView().adapter = placementSupplyAdapter + + customDialogList.getRecyclerView().layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) + + } + + private fun onQuantityOfShelvingSelected(itemShelvingFk:String){ + //1 - MODIFICAR CANTIDAD DEL CARRO + try { + val shelvingVisible = sales[storedPosition].placements[storedShelvingPosition].visible.substring(1,sales[storedPosition].placements[storedShelvingPosition].visible.indexOf(")")) + sales[storedPosition].placements[storedShelvingPosition].visible = + "("+(shelvingVisible.toInt() - customDialogList.getValue().toInt()).toString()+")" + + viewModel.itemShelvingSaleSupplyAdd( + usuario = user, + password = password, + itemShelvingFk = itemShelvingFk, + saleFk = sales[storedPosition].saleFk, + quantity = customDialogList.getValue() + ) + + }catch (e:Exception){} + + //2- MODIFICAR EL PICKED DEL SALE + try{ + sales[storedPosition].startQuantity = (sales[storedPosition].startQuantity.toInt() + customDialogList.getValue().toInt()).toString() + }catch (e:Exception){} + + //3- MARCAR LINEA + if (sales[storedPosition].startQuantity != sales[storedPosition].quantity){ + sales[storedPosition].isPrepared = "1" + markLine(storedPosition, OK) + }else{ + markLine(storedPosition, type) + } + + + } + + //OPTIONS + private fun print(){ + viewModel.collectionStickerPrint( + usuario = user, + password = password, + collectionFk = collection.collectionFk, + sectorFk = sectorFk + ) + "Imprimiendo...".toast(requireContext()) + } + + private fun addItem(){ + listPlacementSupply = ArrayList() + collection.tickets.forEach { + listPlacementSupply.add(BarcodeVO(code = it.ticketFk)) + } + if (listPlacementSupply.size == 1){ + ticketSelected = listPlacementSupply[0].code!! + } + + customDialogList.setTitle("Agregar artículo para ticket: "+ticketSelected).setOkButton("Agregar"){ + if (ticketSelected.isNullOrEmpty()){ + "Selecciona un ticket de la lista".toast(requireContext()) + }else if (customDialogList.getValue().isNullOrEmpty() || customDialogList.getValueTwo().isNullOrEmpty()) { + "Todos los campos son obligatorios".toast(requireContext()) + }else{ + splash_progress.visibility = View.VISIBLE + viewModel.collectionAddItem( + usuario = user, + password = password, + itemFk = customDialogList.getValue(), + ticketFk = ticketSelected, + quantityFk = customDialogList.getValueTwo(), + warehouseFk = warehouseFk + ) + customDialogList.hide() + } + + + }.setKoButton("Cerrar"){ + customDialogList.hide() + }.setHintValue("Artículo:").setValue("").setHintValueTwo("Cantidad:").setValueTwo("").show() + + customDialogList.getEditText().requestFocus() + (activity as MainActivity).hideKeyboard(customDialogList.getEditText()) + + customDialogList.getEditText().setOnEditorActionListener { v, actionId, event -> + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { + if (!customDialogList.getValue().isNullOrEmpty()){ + customDialogList.getEditTextTwo().requestFocus() + } + (activity as MainActivity).hideKeyboard(customDialogList.getEditText()) + return@setOnEditorActionListener true + } + false + } + + customDialogList.getEditTextTwo().setOnEditorActionListener { v, actionId, event -> + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) { + if (!customDialogList.getValueTwo().isNullOrEmpty()){ + if (ticketSelected.isNullOrEmpty()){ + "Selecciona un ticket de la lista".toast(requireContext()) + }else if (customDialogList.getValue().isNullOrEmpty() || customDialogList.getValueTwo().isNullOrEmpty()) { + "Todos los campos son obligatorios".toast(requireContext()) + }else{ + splash_progress.visibility = View.VISIBLE + viewModel.collectionAddItem( + usuario = user, + password = password, + itemFk = customDialogList.getValue(), + ticketFk = ticketSelected, + quantityFk = customDialogList.getValueTwo(), + warehouseFk = warehouseFk + ) + customDialogList.hide() + } + } + (activity as MainActivity).hideKeyboard(customDialogList.getEditTextTwo()) + return@setOnEditorActionListener true + customDialogList.hide() + } + false + } + + placementSupplyAdapter = BarcodeAdapter(listPlacementSupply,object: OnBarcodeRowClickListener { + override fun onBarcodeRowClickListener(item: BarcodeVO) { + customDialogInput.setTitle("Artículo para Ticket: "+item.code!!) + ticketSelected = item.code!! + customDialogList.setTitle("Agregar artículo para ticket: "+ticketSelected) + } + },showDelete = false) + + customDialogList.getRecyclerView().adapter = placementSupplyAdapter + + customDialogList.getRecyclerView().layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) + + + } + + private fun showDisponibility(){ + + customDialogInput.setTitle("Ver disponible").setDescription("Escanea etiqueta: ").setOkButton("Buscar"){ + splash_progress.visibility = View.VISIBLE + (activity as MainActivity).hideKeyboard(customDialogInput.getEditText()) + viewModel.itemGetAvailable( + usuario = user, + password = password, + itemFk = customDialogInput.getValue(), + warehouseFk = warehouseFk + ) + customDialogInput.hide() + + }.setKoButton("Cancelar"){ + splash_progress.visibility = View.GONE + (activity as MainActivity).hideKeyboard(customDialogInput.getEditText()) + customDialogInput.hide() + }.setValue("").show() + customDialogInput.getEditText().requestFocus() + customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event -> + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) { + if (!customDialogInput.getValue().isNullOrEmpty()) { + splash_progress.visibility = View.VISIBLE + viewModel.itemGetAvailable( + usuario = user, + password = password, + itemFk = customDialogInput.getValue(), + warehouseFk = warehouseFk + ) + } + customDialogInput.setValue("") + customDialogInput.hide() + (activity as MainActivity).hideKeyboard(customDialogInput.getEditText()) + return@setOnEditorActionListener true + } + false + } + } + + private fun toastDisponibility(item:ItemVO){ + if (item.available.isNullOrEmpty()){ + item.available = "0" + } + + customDialog.setTitle("Artículo: "+item.id).setDescription("Disponible: "+item.available).setOkButton("Aceptar"){ + customDialog.hide() + }.show() + + } } + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt index 5704234e..dfac0f66 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/fragment/CollectionViewModel.kt @@ -4,7 +4,12 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import es.verdnatura.domain.GetSacadorControladorUserCase import es.verdnatura.presentation.base.BaseViewModel +import es.verdnatura.presentation.common.ResponseItemVO +import es.verdnatura.presentation.view.feature.collection.ItemVO +import es.verdnatura.presentation.view.feature.collection.mapper.map import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO +import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyListVO +import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO import retrofit2.Call import retrofit2.Callback import retrofit2.Response @@ -19,6 +24,23 @@ class CollectionViewModel : BaseViewModel() { val collectionTicketList: LiveData get() = _collectionTicketList + private val _placementSuppleyList by lazy { MutableLiveData() } + val placementSuppleyList: LiveData + get() = _placementSuppleyList + + private val _response by lazy { MutableLiveData() } + val response: LiveData + get() = _response + + private val _responseNew by lazy { MutableLiveData() } + val responseNew: LiveData + get() = _responseNew + + + private val _item by lazy { MutableLiveData() } + val item: LiveData + get() = _item + fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String){ getSacadorControladorUserCase.collectionTicketGet(usuario,password,collectionFk,sectorFk).enqueue(object : @@ -31,11 +53,114 @@ class CollectionViewModel : BaseViewModel() { response: Response ) { if (response.body() != null){ - _collectionTicketList.value = response.body()?.let { it } + _collectionTicketList.value = response.body()?.let { it.map() } }else{ _collectionTicketList.value = CollectionVO(isError = true,errorMessage = "Error en la llamada de collection_get") } } }) } + + fun saleTrackingReplace(usuario:String,password:String,saleFk:String,vOriginalQuantity:String,vStateFk:String,vIsChecked:String){ + getSacadorControladorUserCase.saleTrackingReplace(usuario,password,saleFk,vOriginalQuantity,vStateFk,vIsChecked).enqueue(object : Callback{ + override fun onFailure(call: Call, t: Throwable) { + _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) + } + + override fun onResponse(call: Call, response: Response) { + if (response.body() == null){ + _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada saleTracking_Replace") + }else{ + _response.value = ResponseItemVO(isError = false,response = response.body()!!) + } + } + }) + } + + fun itemPlacementSupplyAiming(usuario:String,password:String,shelvingFk:String,quantity:String,itemFk:String){ + getSacadorControladorUserCase.itemPlacementSupplyAiming(usuario,password,shelvingFk,quantity,itemFk).enqueue(object : + Callback> { + override fun onFailure(call: Call>, t: Throwable) { + val listError:ArrayList = ArrayList() + listError.add(PlacementSupplyVO(isError = true,errorMessage = t.message!!)) + _placementSuppleyList.value = PlacementSupplyListVO(listError) + } + override fun onResponse( + call: Call>, + response: Response> + ) { + if (response.body() != null){ + _placementSuppleyList.value = response.body()?.let { PlacementSupplyListVO(it) } + }else{ + val listError:ArrayList = ArrayList() + listError.add(PlacementSupplyVO(isError = true,errorMessage = "Error en la llamada de itemPlacementSupplyAiming")) + _placementSuppleyList.value = PlacementSupplyListVO(listError) + } + } + }) + } + + fun itemShelvingSaleSupplyAdd(usuario:String,password:String,itemShelvingFk:String,saleFk:String,quantity:String){ + getSacadorControladorUserCase.itemShelvingSaleSupplyAdd(usuario,password,itemShelvingFk,saleFk,quantity).enqueue(object : Callback{ + override fun onFailure(call: Call, t: Throwable) { + _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) + } + + override fun onResponse(call: Call, response: Response) { + if (response.body() == null){ + _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemShelvingSaleSupplyAdd") + }else{ + _response.value = ResponseItemVO(isError = false,response = response.body()!!) + } + } + }) + } + + fun collectionStickerPrint(usuario:String,password:String,collectionFk: String,sectorFk: String){ + getSacadorControladorUserCase.collectionStickerPrint(usuario,password,collectionFk,sectorFk).enqueue(object : Callback{ + override fun onFailure(call: Call, t: Throwable) { + _response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) + } + + override fun onResponse(call: Call, response: Response) { + if (response.body() == null){ + _response.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionStickerPrint") + }else{ + _response.value = ResponseItemVO(isError = false,response = response.body()!!) + } + } + }) + } + + fun itemGetAvailable(usuario:String,password:String,itemFk: String,warehouseFk: String){ + getSacadorControladorUserCase.itemGetAvailable(usuario,password,itemFk,warehouseFk).enqueue(object : Callback{ + override fun onFailure(call: Call, t: Throwable) { + _item.value = ItemVO(isError = true,errorMessage = ""+t.message!!) + } + + override fun onResponse(call: Call, response: Response) { + if (response.body() == null){ + _item.value = ItemVO(isError = true,errorMessage = "Error en la llamada item_GetVisibleAvailable") + }else{ + _item.value = response.body() + } + } + }) + } + + fun collectionAddItem(usuario:String,password:String,itemFk: String,quantityFk: String,ticketFk: String,warehouseFk: String){ + getSacadorControladorUserCase.collectionAddItem(usuario,password,itemFk,quantityFk,ticketFk,warehouseFk).enqueue(object : Callback{ + override fun onFailure(call: Call, t: Throwable) { + _responseNew.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!) + } + + override fun onResponse(call: Call, response: Response) { + if (response.body() == null){ + _responseNew.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionStickerPrint") + }else{ + _responseNew.value = ResponseItemVO(isError = false,response = response.body()!!) + } + } + }) + } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/collection/mapper/CollectionMapper.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/mapper/CollectionMapper.kt new file mode 100644 index 00000000..49553715 --- /dev/null +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/collection/mapper/CollectionMapper.kt @@ -0,0 +1,37 @@ +package es.verdnatura.presentation.view.feature.collection.mapper + +import es.verdnatura.presentation.common.convertToDateString +import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO +import java.lang.NumberFormatException +import java.text.SimpleDateFormat +import java.util.* + +fun CollectionVO.map() : CollectionVO{ + this.tickets.forEach {ticket -> + ticket.sales.forEach { + it.ticketFk = ticket.ticketFk + it.level = ticket.level + it.agencyName = ticket.agencyName + it.quantity = it.quantity.substring(0,it.quantity.indexOf(".")) + if (it.placements.isNotEmpty()){ + try{ + it.saleOrder = it.placements[0].saleOrder.toInt() + }catch (e:NumberFormatException){ + it.saleOrder = 9999 + } + } + it.placements.forEach { placement -> + placement.created = getCalendarFromDate(placement.created).convertToDateString() + placement.visible = "("+placement.visible+")" + } + } + } + return this +} + +private fun getCalendarFromDate(date:String): Calendar { + val sdf = SimpleDateFormat("yyyy-MM-dd") + val cal = Calendar.getInstance() + cal.setTime(sdf.parse(date)) + return cal +} \ No newline at end of file diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt index 00481e4b..ed67aa17 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/main/activity/MainActivity.kt @@ -229,8 +229,8 @@ class MainActivity : BaseActivity() , OnPasillerosItemClick addFragmentOnTop(ExpeditionPalletDetailFragment.newInstance(itemTruck,itemPallet)) } - override fun onCollectionSelected(collection: CollectionVO) { - addFragmentOnTop(CollectionFragment.newInstance(collection)) + override fun onCollectionSelected(collection: CollectionVO,type:Int) { + addFragmentOnTop(CollectionFragment.newInstance(collection,type)) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/adapter/CollectionAdapter.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/adapter/CollectionAdapter.kt index 829e92dd..463acca4 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/adapter/CollectionAdapter.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/adapter/CollectionAdapter.kt @@ -4,6 +4,7 @@ import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import es.verdnatura.databinding.ItemCollectionRowBinding +import es.verdnatura.domain.ConstAndValues.SACADOR import es.verdnatura.presentation.common.OnCollectionSelectedListener import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO @@ -24,7 +25,7 @@ class CollectionAdapter ( override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) { holder.bind(items[position]) holder.binding.root.setOnClickListener { - onCollectionSelected.onCollectionSelected(items[position]) + onCollectionSelected.onCollectionSelected(items[position],SACADOR) } } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragment.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragment.kt index fbd42065..7c5c8fcf 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragment.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/fragment/SacadorFragment.kt @@ -9,6 +9,7 @@ import androidx.lifecycle.Observer import androidx.recyclerview.widget.LinearLayoutManager import es.verdnatura.R import es.verdnatura.databinding.FragmentSacadorBinding +import es.verdnatura.domain.ConstAndValues.SACADOR import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.common.OnCollectionSelectedListener import es.verdnatura.presentation.common.OnOptionsSelectedListener @@ -113,8 +114,8 @@ class SacadorFragment : BaseFragment(Sa private fun navigateToCollectionList(collection:CollectionVO){ - splash_progress.visibility = View.GONE - // onCollectionSelectedListener!!.onCollectionSelected(collection) + viewModel.collectionGet(user,password) + } diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/model/TicketItemVO.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/model/TicketItemVO.kt index 7984037a..f4d0b7f2 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/model/TicketItemVO.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/sacador/model/TicketItemVO.kt @@ -20,6 +20,9 @@ class TicketVO( ) class SaleVO( var ticketFk : String = "", + var level : String = "", + var agencyName : String = "", + var saleOrder : Int = 9999, var saleFk : String = "", var itemFk : String = "", var quantity : String = "", @@ -65,5 +68,23 @@ class PlacementVO( var id : String = "" ) +class PlacementSupplyVO( + var itemFk : String = "", + var longName : String = "", + var size : String = "", + var subName : String = "", + var itemShelvingFk : String = "", + var shelving : String = "", + var stock : String = "", + var total : String = "", + var proposal : String = "", + var isError: Boolean = false, + var errorMessage: String = "" +) + +class PlacementSupplyListVO ( + var list: List = listOf() +) + diff --git a/app/src/main/res/drawable/ic_playlist_add_black_24dp.xml b/app/src/main/res/drawable/ic_playlist_add_black_24dp.xml new file mode 100644 index 00000000..87a821f0 --- /dev/null +++ b/app/src/main/res/drawable/ic_playlist_add_black_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_visibility.xml b/app/src/main/res/drawable/ic_visibility.xml new file mode 100644 index 00000000..1e902323 --- /dev/null +++ b/app/src/main/res/drawable/ic_visibility.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/component_custom_list_dialog.xml b/app/src/main/res/layout/component_custom_list_dialog.xml index 83bccc07..628ccb99 100644 --- a/app/src/main/res/layout/component_custom_list_dialog.xml +++ b/app/src/main/res/layout/component_custom_list_dialog.xml @@ -52,6 +52,28 @@ android:textColorHint="@android:color/darker_gray" /> + + + + + + + type="es.verdnatura.presentation.view.feature.sacador.fragment.SacadorViewModel" /> + + + + + + + + app:layout_constraintTop_toBottomOf="@+id/scan"> + + + tools:listitem="@layout/item_article_row" /> + + type="es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel" /> + xmlns:tool="http://schemas.android.com/tools" + xmlns:tools="http://schemas.android.com/tools"> + android:orientation="vertical" + android:layout_marginBottom="@dimen/layout_margin_min"> + + android:background="@color/verdnatura_black_5"> + + + + + + + + + + + + + + - + android:layout_height="wrap_content" + android:paddingTop="@dimen/layout_margin_min" + android:paddingBottom="@dimen/layout_margin_min" + android:background="@color/verdnatura_black"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_placement_row.xml b/app/src/main/res/layout/item_placement_row.xml new file mode 100644 index 00000000..6efb5827 --- /dev/null +++ b/app/src/main/res/layout/item_placement_row.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 499bac22..eed2361c 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -69,12 +69,15 @@ 15dp 300dp - 40dp 10dp 40dp 33dp + + 20dp + 30dp + \ No newline at end of file