collections v2

This commit is contained in:
Enrique Blasco 2020-06-23 11:58:02 +02:00
parent fdf4e54e22
commit 56d84a2a86
27 changed files with 1371 additions and 45 deletions

View File

@ -57,6 +57,7 @@ dependencies {
implementation 'com.squareup.retrofit2:converter-gson:2.0.2' implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'
implementation "com.airbnb.android:lottie:$lottieVersion" implementation "com.airbnb.android:lottie:$lottieVersion"
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
// Architecture components // Architecture components

View File

@ -8,7 +8,7 @@ import java.util.concurrent.TimeUnit
class ApiUtils { class ApiUtils {
companion object { 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/" //const val BASE_URL:String = "https://app.verdnatura.es/"
fun getApiService():VerdnaturaService{ fun getApiService():VerdnaturaService{
val retrofit = Retrofit.Builder() val retrofit = Retrofit.Builder()

View File

@ -0,0 +1,8 @@
package es.verdnatura.domain
object ConstAndValues {
const val SACADOR = 14
const val CONTROLADOR = 8
const val OK = 3
}

View File

@ -3,7 +3,7 @@ package es.verdnatura.domain
import android.content.Context import android.content.Context
import android.widget.Toast 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() } return Toast.makeText(context, this.toString(), duration).apply { show() }
} }

View File

@ -1,6 +1,8 @@
package es.verdnatura.domain 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.CollectionVO
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO
import retrofit2.Call import retrofit2.Call
class GetSacadorControladorUserCase : RestClient() { class GetSacadorControladorUserCase : RestClient() {
@ -17,4 +19,52 @@ class GetSacadorControladorUserCase : RestClient() {
return restClient!!.collectionGet("json","1",usuario,password,"application/json") return restClient!!.collectionGet("json","1",usuario,password,"application/json")
} }
fun saleTrackingReplace(usuario:String,password:String,saleFk:String,vOriginalQuantity:String,vStateFk:String,vIsChecked:String) : Call<String> {
val params:ArrayList<String> = 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<List<PlacementSupplyVO>> {
val params:ArrayList<String> = 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<String> {
val params:ArrayList<String> = 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<String> {
val params:ArrayList<String> = 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<ItemVO> {
val params:ArrayList<String> = 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<String> {
val params:ArrayList<String> = ArrayList()
params.add(itemFk)
params.add(quantityFk)
params.add(ticketFk)
params.add(warehouseFk)
return restClient!!.collectionAddItem("json","1",usuario,password,"application/json",params)
}
} }

View File

@ -5,11 +5,14 @@ package es.verdnatura.domain
import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO import es.verdnatura.presentation.view.feature.ajustes.model.SectorItemVO
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO
import es.verdnatura.presentation.view.feature.buscaritem.model.ItemLocationVO 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.faltas.model.ItemFaltasVO
import es.verdnatura.presentation.view.feature.historico.model.ItemHistoricoVO import es.verdnatura.presentation.view.feature.historico.model.ItemHistoricoVO
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
import es.verdnatura.presentation.view.feature.paletizador.model.* 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.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.shelvingparking.model.ItemShelvingParkingVO
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
import retrofit2.Call import retrofit2.Call
@ -69,6 +72,60 @@ interface VerdnaturaService {
@Body params: List<String>): @Body params: List<String>):
Call<CollectionVO> Call<CollectionVO>
@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<String>):
Call<String>
@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<String>):
Call<List<PlacementSupplyVO>>
@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<String>):
Call<String>
@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<String>):
Call<String>
@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<String>):
Call<ItemVO>
@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<String>):
Call<String>
//PASILLEROS ========================================================================> //PASILLEROS ========================================================================>
//CONSULTAR ARTICULO ========================================================================> //CONSULTAR ARTICULO ========================================================================>

View File

@ -81,5 +81,5 @@ interface OnScanLongClickListener {
} }
interface OnCollectionSelectedListener { interface OnCollectionSelectedListener {
fun onCollectionSelected(collection: CollectionVO) fun onCollectionSelected(collection: CollectionVO,type:Int)
} }

View File

@ -7,11 +7,13 @@ import android.graphics.drawable.Drawable
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.widget.ImageView import android.widget.ImageView
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction import androidx.fragment.app.FragmentTransaction
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.CustomTarget import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition import com.bumptech.glide.request.transition.Transition
@ -114,3 +116,13 @@ fun Calendar.convertToDateString(): String {
return dayOfWeek + " " + day + " " + dayOfMonth 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()
}
})
}

View File

@ -23,6 +23,10 @@ class CustomDialogList (context: Context) : Dialog(context, R.style.DialogTheme)
return custom_dialog_value return custom_dialog_value
} }
fun getEditTextTwo() : TextInputEditText {
return custom_dialog_value_two
}
fun getValue() : String { fun getValue() : String {
return custom_dialog_value.text.toString() return custom_dialog_value.text.toString()
} }
@ -33,6 +37,16 @@ class CustomDialogList (context: Context) : Dialog(context, R.style.DialogTheme)
return this 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 { fun setTitle(title: String): CustomDialogList {
custom_dialog_title.visibility = View.VISIBLE custom_dialog_title.visibility = View.VISIBLE
custom_dialog_title.text = title custom_dialog_title.text = title
@ -54,4 +68,14 @@ class CustomDialogList (context: Context) : Dialog(context, R.style.DialogTheme)
return this 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
}
} }

View File

@ -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 = ""
)

View File

@ -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<PlacementVO>
): RecyclerView.Adapter<PlacementAdapter.AjustesItemHolder> () {
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
}
}
}
}

View File

@ -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<SaleVO>,
private val onPasillerosItemClickListener: OnPasillerosItemClickListener
): RecyclerView.Adapter<SaleAdapter.AjustesItemHolder> () {
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))
}
}
}
}
}

View File

@ -3,42 +3,74 @@ package es.verdnatura.presentation.view.feature.collection.fragment
import android.content.Context import android.content.Context
import android.content.SharedPreferences import android.content.SharedPreferences
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import androidx.lifecycle.ViewModelProviders import android.media.MediaPlayer
import android.os.Bundle import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.inputmethod.EditorInfo
import android.widget.Toast
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R import es.verdnatura.R
import es.verdnatura.databinding.FragmentCollectionBinding 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.base.BaseFragment
import es.verdnatura.presentation.common.OnBarcodeRowClickListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener 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.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.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.activity_main.*
import kotlinx.android.synthetic.main.fragment_collection.* import kotlinx.android.synthetic.main.fragment_collection.*
import kotlinx.android.synthetic.main.fragment_collection.splash_progress
import kotlinx.android.synthetic.main.toolbar.* import kotlinx.android.synthetic.main.toolbar.*
class CollectionFragment( class CollectionFragment(
var collection : CollectionVO = CollectionVO() var collection : CollectionVO = CollectionVO(),
var type:Int = SACADOR
) : BaseFragment<FragmentCollectionBinding,CollectionViewModel>(CollectionViewModel::class){ ) : BaseFragment<FragmentCollectionBinding,CollectionViewModel>(CollectionViewModel::class){
private var user = "" private var user = ""
private var password = "" private var password = ""
private var sectorFk = "" private var sectorFk = ""
private var warehouseFk = "" private var warehouseFk = ""
private var sales:List<SaleVO> = 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<BarcodeVO> = 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 { companion object {
fun newInstance(collection:CollectionVO) = CollectionFragment(collection) fun newInstance(collection:CollectionVO,type:Int) = CollectionFragment(collection,type)
} }
override fun onAttach(context: Context) { override fun onAttach(context: Context) {
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
super.onAttach(context) super.onAttach(context)
} }
override fun getLayoutId(): Int = R.layout.fragment_collection override fun getLayoutId(): Int = R.layout.fragment_collection
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
@ -47,6 +79,8 @@ class CollectionFragment(
password = prefs.getString(PASSWORD,"").toString() password = prefs.getString(PASSWORD,"").toString()
sectorFk = prefs.getInt(SECTORFK,1).toString() sectorFk = prefs.getInt(SECTORFK,1).toString()
warehouseFk = prefs.getInt(WAREHOUSEFK,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()){ if (collection.tickets.isEmpty()){
viewModel.collectionTicketGet(user,password,collection.collectionFk,sectorFk) viewModel.collectionTicketGet(user,password,collection.collectionFk,sectorFk)
}else{ }else{
@ -57,6 +91,9 @@ class CollectionFragment(
} }
override fun init() { override fun init() {
customDialogList = CustomDialogList(requireContext())
customDialogInput = CustomDialogInput(requireContext())
customDialog = CustomDialog(requireContext())
activity!!.main_bottom_navigation.visibility = View.GONE activity!!.main_bottom_navigation.visibility = View.GONE
splash_progress.visibility = View.VISIBLE splash_progress.visibility = View.VISIBLE
toolbar_title.text = "collectionTicket_get" toolbar_title.text = "collectionTicket_get"
@ -65,15 +102,29 @@ class CollectionFragment(
super.init() super.init()
} }
override fun onPause() {
goBack = true
super.onPause()
}
private fun setToolBar(){ private fun setToolBar(){
val listIcons:ArrayList<Drawable> = ArrayList() val listIcons:ArrayList<Drawable> = ArrayList()
val iconReload : Drawable = resources.getDrawable(R.drawable.ic_autorenew_black_24dp,resources.newTheme()) val iconPrint : Drawable = resources.getDrawable(R.drawable.ic_print_black_24dp,resources.newTheme())
listIcons.add(iconReload) 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 { toolbar_icons.adapter = ToolBarAdapter(listIcons,object: OnOptionsSelectedListener {
override fun onOptionsItemSelected(item: Drawable) { override fun onOptionsItemSelected(item: Drawable) {
if (item == iconReload){ if (item == iconPrint){
splash_progress.visibility = View.VISIBLE print()
viewModel.collectionTicketGet(user,password,collection.collectionFk,sectorFk) }else if (item == iconSearch){
showDisponibility()
}else if (item == iconAdd){
addItem()
} }
} }
}) })
@ -84,6 +135,26 @@ class CollectionFragment(
backButton.setOnClickListener { backButton.setOnClickListener {
activity!!.onBackPressed() 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() { override fun observeViewModel() {
@ -100,13 +171,457 @@ class CollectionFragment(
} }
}) })
}
}
placementSuppleyList.observe(viewLifecycleOwner, Observer {
private fun createCollectionList(){
splash_progress.visibility = View.GONE splash_progress.visibility = View.GONE
Log.i("Collection",collection.collectionFk) 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
var salesList:ArrayList<SaleVO> = 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()
}
}

View File

@ -4,7 +4,12 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetSacadorControladorUserCase import es.verdnatura.domain.GetSacadorControladorUserCase
import es.verdnatura.presentation.base.BaseViewModel 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.CollectionVO
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyListVO
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO
import retrofit2.Call import retrofit2.Call
import retrofit2.Callback import retrofit2.Callback
import retrofit2.Response import retrofit2.Response
@ -19,6 +24,23 @@ class CollectionViewModel : BaseViewModel() {
val collectionTicketList: LiveData<CollectionVO> val collectionTicketList: LiveData<CollectionVO>
get() = _collectionTicketList get() = _collectionTicketList
private val _placementSuppleyList by lazy { MutableLiveData<PlacementSupplyListVO>() }
val placementSuppleyList: LiveData<PlacementSupplyListVO>
get() = _placementSuppleyList
private val _response by lazy { MutableLiveData<ResponseItemVO>() }
val response: LiveData<ResponseItemVO>
get() = _response
private val _responseNew by lazy { MutableLiveData<ResponseItemVO>() }
val responseNew: LiveData<ResponseItemVO>
get() = _responseNew
private val _item by lazy { MutableLiveData<ItemVO>() }
val item: LiveData<ItemVO>
get() = _item
fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String){ fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String){
getSacadorControladorUserCase.collectionTicketGet(usuario,password,collectionFk,sectorFk).enqueue(object : getSacadorControladorUserCase.collectionTicketGet(usuario,password,collectionFk,sectorFk).enqueue(object :
@ -31,11 +53,114 @@ class CollectionViewModel : BaseViewModel() {
response: Response<CollectionVO> response: Response<CollectionVO>
) { ) {
if (response.body() != null){ if (response.body() != null){
_collectionTicketList.value = response.body()?.let { it } _collectionTicketList.value = response.body()?.let { it.map() }
}else{ }else{
_collectionTicketList.value = CollectionVO(isError = true,errorMessage = "Error en la llamada de collection_get") _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<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
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<List<PlacementSupplyVO>> {
override fun onFailure(call: Call<List<PlacementSupplyVO>>, t: Throwable) {
val listError:ArrayList<PlacementSupplyVO> = ArrayList()
listError.add(PlacementSupplyVO(isError = true,errorMessage = t.message!!))
_placementSuppleyList.value = PlacementSupplyListVO(listError)
}
override fun onResponse(
call: Call<List<PlacementSupplyVO>>,
response: Response<List<PlacementSupplyVO>>
) {
if (response.body() != null){
_placementSuppleyList.value = response.body()?.let { PlacementSupplyListVO(it) }
}else{
val listError:ArrayList<PlacementSupplyVO> = 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<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
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<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
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<ItemVO>{
override fun onFailure(call: Call<ItemVO>, t: Throwable) {
_item.value = ItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<ItemVO>, response: Response<ItemVO>) {
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<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_responseNew.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_responseNew.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionStickerPrint")
}else{
_responseNew.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
} }

View File

@ -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
}

View File

@ -229,8 +229,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>() , OnPasillerosItemClick
addFragmentOnTop(ExpeditionPalletDetailFragment.newInstance(itemTruck,itemPallet)) addFragmentOnTop(ExpeditionPalletDetailFragment.newInstance(itemTruck,itemPallet))
} }
override fun onCollectionSelected(collection: CollectionVO) { override fun onCollectionSelected(collection: CollectionVO,type:Int) {
addFragmentOnTop(CollectionFragment.newInstance(collection)) addFragmentOnTop(CollectionFragment.newInstance(collection,type))
} }
} }

View File

@ -4,6 +4,7 @@ import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.databinding.ItemCollectionRowBinding import es.verdnatura.databinding.ItemCollectionRowBinding
import es.verdnatura.domain.ConstAndValues.SACADOR
import es.verdnatura.presentation.common.OnCollectionSelectedListener import es.verdnatura.presentation.common.OnCollectionSelectedListener
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
@ -24,7 +25,7 @@ class CollectionAdapter (
override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) { override fun onBindViewHolder(holder: AjustesItemHolder, position: Int) {
holder.bind(items[position]) holder.bind(items[position])
holder.binding.root.setOnClickListener { holder.binding.root.setOnClickListener {
onCollectionSelected.onCollectionSelected(items[position]) onCollectionSelected.onCollectionSelected(items[position],SACADOR)
} }
} }

View File

@ -9,6 +9,7 @@ import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R import es.verdnatura.R
import es.verdnatura.databinding.FragmentSacadorBinding import es.verdnatura.databinding.FragmentSacadorBinding
import es.verdnatura.domain.ConstAndValues.SACADOR
import es.verdnatura.presentation.base.BaseFragment import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnCollectionSelectedListener import es.verdnatura.presentation.common.OnCollectionSelectedListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener import es.verdnatura.presentation.common.OnOptionsSelectedListener
@ -113,8 +114,8 @@ class SacadorFragment : BaseFragment<FragmentSacadorBinding,SacadorViewModel>(Sa
private fun navigateToCollectionList(collection:CollectionVO){ private fun navigateToCollectionList(collection:CollectionVO){
splash_progress.visibility = View.GONE viewModel.collectionGet(user,password)
// onCollectionSelectedListener!!.onCollectionSelected(collection)
} }

View File

@ -20,6 +20,9 @@ class TicketVO(
) )
class SaleVO( class SaleVO(
var ticketFk : String = "", var ticketFk : String = "",
var level : String = "",
var agencyName : String = "",
var saleOrder : Int = 9999,
var saleFk : String = "", var saleFk : String = "",
var itemFk : String = "", var itemFk : String = "",
var quantity : String = "", var quantity : String = "",
@ -65,5 +68,23 @@ class PlacementVO(
var id : String = "" 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<PlacementSupplyVO> = listOf()
)

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFF" android:pathData="M14,10L2,10v2h12v-2zM14,6L2,6v2h12L14,6zM18,14v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zM2,16h8v-2L2,14v2z"/>
</vector>

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFF" android:pathData="M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z"/>
</vector>

View File

@ -52,6 +52,28 @@
android:textColorHint="@android:color/darker_gray" /> android:textColorHint="@android:color/darker_gray" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textinputlayout_two"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="@android:color/darker_gray"
android:layout_marginTop="@dimen/layout_margin_min"
android:visibility="gone">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/custom_dialog_value_two"
style="@style/InputLineTextSearch"
android:layout_width="match_parent"
android:backgroundTint="@android:color/white"
android:hint="Cantidad"
android:inputType="number"
android:lines="1"
android:maxLines="1"
android:textColor="@color/verdnatura_white"
android:textColorHint="@android:color/darker_gray" />
</com.google.android.material.textfield.TextInputLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/item_recyclerview" android:id="@+id/item_recyclerview"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -6,7 +6,7 @@
<data> <data>
<variable <variable
name="viewModel" name="viewModel"
type="es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel" /> type="es.verdnatura.presentation.view.feature.sacador.fragment.SacadorViewModel" />
</data> </data>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
@ -15,25 +15,55 @@
android:background="@color/verdnatura_black"> android:background="@color/verdnatura_black">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/scan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="@android:color/darker_gray"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/main_toolbar">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/scan_input"
style="@style/InputLineTextSearch"
android:layout_width="match_parent"
android:backgroundTint="@android:color/white"
android:hint="Escaner"
android:inputType="text"
android:lines="1"
android:maxLines="1"
android:textColor="@color/verdnatura_white"
android:textColorHint="@android:color/darker_gray" />
</com.google.android.material.textfield.TextInputLayout>
<ViewSwitcher <ViewSwitcher
android:id="@+id/collection_switcher" android:id="@+id/collection_switcher"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toBottomOf="@+id/scan">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/collection_swipe"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/fragment_collection_items" android:id="@+id/fragment_sacador_collections"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:paddingTop="@dimen/toolbar_height" tools:listitem="@layout/item_article_row" />
tools:listitem="@layout/item_collection_row" /> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<TextView <TextView
android:id="@+id/collection_empty_text" android:id="@+id/sacador_empty_text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/navigation_item_height" android:layout_height="@dimen/navigation_item_height"
android:gravity="center" android:gravity="center"

View File

@ -6,7 +6,7 @@
<data> <data>
<variable <variable
name="viewModel" name="viewModel"
type="es.verdnatura.presentation.view.feature.sacador.fragment.SacadorViewModel" /> type="es.verdnatura.presentation.view.feature.collection.fragment.CollectionViewModel" />
</data> </data>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
@ -33,7 +33,7 @@
tools:listitem="@layout/item_collection_row" /> tools:listitem="@layout/item_collection_row" />
<TextView <TextView
android:id="@+id/sacador_empty_text" android:id="@+id/collection_empty_text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/navigation_item_height" android:layout_height="@dimen/navigation_item_height"
android:gravity="center" android:gravity="center"

View File

@ -1,31 +1,242 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android" <layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tool="http://schemas.android.com/tools"> xmlns:tool="http://schemas.android.com/tools"
xmlns:tools="http://schemas.android.com/tools">
<data> <data>
<variable <variable
name="item" name="sale"
type="es.verdnatura.presentation.view.feature.sacador.model.SaleVO" /> type="es.verdnatura.presentation.view.feature.sacador.model.SaleVO" />
</data> </data>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical"
android:layout_marginBottom="@dimen/layout_margin_min">
<!--CABECERA=================================================-->
<LinearLayout <LinearLayout
android:id="@+id/item_row_layout" android:id="@+id/item_row_layout"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/verdnatura_black_5" android:background="@color/verdnatura_black_5">
android:padding="@dimen/pasilleros_margin_main_menu">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/verdnatura_warm_grey"
android:padding="@dimen/layout_margin_min"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/verdnatura_white"
android:text="Nivel:"
android:textSize="@dimen/h8"
android:layout_marginRight="@dimen/layout_margin_min"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/verdnatura_white"
android:text="@{sale.level}"
tool:text="2"
android:textStyle="bold"
android:textSize="@dimen/h8"
android:layout_marginRight="@dimen/layout_margin_min"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/verdnatura_white"
android:text="Ticket:"
android:textSize="@dimen/h8"
android:layout_marginRight="@dimen/layout_margin_min"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/verdnatura_white"
android:text="@{sale.ticketFk}"
tool:text="123456789"
android:textStyle="bold"
android:textSize="@dimen/h8"/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="wrap_content"
android:background="@color/verdnatura_black_9"/> android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/verdnatura_white"
android:text="Agencia:"
android:textSize="@dimen/h8"
android:layout_marginRight="@dimen/layout_margin_min"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/verdnatura_white"
android:text="@{sale.agencyName}"
tool:text="MRW"
android:textStyle="bold"
android:textSize="@dimen/h8"
android:layout_marginRight="@dimen/layout_margin_min"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/content_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/layout_margin_min"
android:paddingBottom="@dimen/layout_margin_min"
android:background="@color/verdnatura_black">
<!--SEMAFORO=================================================-->
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="@dimen/semaforo_width"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<View
android:id="@+id/item_article_row_semaforo_pre"
android:layout_width="match_parent"
android:layout_height="@dimen/semaforo_height"
android:background="@color/verdnatura_warm_grey"
android:layout_marginBottom="1dp"/>
<View
android:id="@+id/item_article_row_semaforo_sac"
android:layout_width="match_parent"
android:layout_height="@dimen/semaforo_height"
android:background="@color/verdnatura_warm_grey"
android:layout_marginBottom="1dp"/>
<View
android:id="@+id/item_article_row_semaforo_con"
android:layout_width="match_parent"
android:layout_height="@dimen/semaforo_height"
android:background="@color/verdnatura_warm_grey" />
</LinearLayout>
<!--CONTENIDO=================================================-->
<TextView
android:id="@+id/item_article_itemFk"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/layout_margin_min"
android:layout_marginEnd="@dimen/layout_margin_min"
android:text="@{sale.itemFk}"
tool:text="85478"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/h6"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@+id/item_article_quantity_picked"
app:layout_constraintStart_toEndOf="@+id/linearLayout3"
app:layout_constraintTop_toTopOf="parent"
android:maxLines="1"/>
<TextView
android:id="@+id/item_article_quantity_picked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/layout_margin_min"
android:text="@{sale.startQuantity}"
tool:text="0"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/h6"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@+id/txtde"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/txtde"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/layout_margin_min"
android:text="de"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/h6"
app:layout_constraintEnd_toStartOf="@+id/item_article_quantity"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/item_article_quantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/layout_margin_min"
android:text="@{sale.quantity}"
tool:text="10"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/h6"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/item_article_quantity_line1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/layout_margin_min"
android:ellipsize="end"
android:maxLines="1"
android:text="@{sale.line1}"
tool:text="información de la linea 1"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/body2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/linearLayout3"
app:layout_constraintTop_toBottomOf="@+id/item_article_itemFk" />
<TextView
android:id="@+id/item_article_quantity_line2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/layout_margin_min"
android:ellipsize="end"
android:maxLines="1"
android:text="@{sale.line2}"
tool:text="información de la linea 2"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/body2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/linearLayout3"
app:layout_constraintTop_toBottomOf="@+id/item_article_quantity_line1" />
<TextView
android:id="@+id/item_article_quantity_line3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/layout_margin_min"
android:ellipsize="end"
android:maxLines="1"
android:text="@{sale.line3}"
tool:text="información de la linea 3"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/body2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/linearLayout3"
app:layout_constraintTop_toBottomOf="@+id/item_article_quantity_line2" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/item_article_placements"
android:clipToPadding="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_placement_row"
android:background="@color/verdnatura_black_3"
tools:orientation="horizontal"/>
</LinearLayout> </LinearLayout>
</layout> </layout>

View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tool="http://schemas.android.com/tools">
<data>
<variable
name="item"
type="es.verdnatura.presentation.view.feature.sacador.model.PlacementVO" />
</data>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/layout_margin_1"
android:gravity="center"
android:layout_marginEnd="@dimen/layout_margin_min">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{item.placement}"
tool:text="053-05"
android:textColor="@color/verdnatura_pumpkin_orange"
android:textStyle="bold"
android:textSize="@dimen/h7"
android:layout_marginEnd="@dimen/layout_margin_min"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{item.shelving}"
tool:text="YIC"
android:textColor="@color/verdnatura_white"
android:textStyle="bold"
android:textSize="@dimen/h8"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{item.created}"
tool:text="28/05 "
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/h8"
android:layout_marginEnd="@dimen/layout_margin_min"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{item.visible}"
tool:text="260"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/h8"/>
</LinearLayout>
</LinearLayout>
</layout>

View File

@ -69,12 +69,15 @@
<!--Pasilleros--> <!--Pasilleros-->
<dimen name="pasilleros_margin_main_menu">15dp</dimen> <dimen name="pasilleros_margin_main_menu">15dp</dimen>
<dimen name="itemcard_image_height">300dp</dimen> <dimen name="itemcard_image_height">300dp</dimen>
<dimen name="options_image_width">40dp</dimen> <dimen name="options_image_width">40dp</dimen>
<dimen name="options_image_padding">10dp</dimen> <dimen name="options_image_padding">10dp</dimen>
<dimen name="item_image_width">40dp</dimen> <dimen name="item_image_width">40dp</dimen>
<dimen name="item_image_width_min">33dp</dimen> <dimen name="item_image_width_min">33dp</dimen>
<!-- Sacadores -->
<dimen name="semaforo_width">20dp</dimen>
<dimen name="semaforo_height">30dp</dimen>
</resources> </resources>