Pre-sacador
This commit is contained in:
parent
42bcd8cebd
commit
d0b8c97b1f
|
@ -12,8 +12,8 @@ android {
|
||||||
applicationId "es.verdnatura"
|
applicationId "es.verdnatura"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 16
|
versionCode 19
|
||||||
versionName "5.0.16"
|
versionName "5.0.19"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,9 @@ import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionPa
|
||||||
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionPalletViewModel
|
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionPalletViewModel
|
||||||
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionScanViewModel
|
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionScanViewModel
|
||||||
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionTruckListViewModel
|
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionTruckListViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.parking.fragment.ParkingViewModel
|
||||||
import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroViewModel
|
import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroViewModel
|
||||||
|
import es.verdnatura.presentation.view.feature.presacador.fragment.PreSacadorViewModel
|
||||||
import es.verdnatura.presentation.view.feature.sacador.fragment.SacadorViewModel
|
import es.verdnatura.presentation.view.feature.sacador.fragment.SacadorViewModel
|
||||||
import es.verdnatura.presentation.view.feature.shelvingparking.fragment.ShelvingParkingViewModel
|
import es.verdnatura.presentation.view.feature.shelvingparking.fragment.ShelvingParkingViewModel
|
||||||
import es.verdnatura.presentation.view.feature.ubicador.fragment.AutomaticAddItemViewModel
|
import es.verdnatura.presentation.view.feature.ubicador.fragment.AutomaticAddItemViewModel
|
||||||
|
@ -105,4 +107,12 @@ val viewModelModule = module{
|
||||||
viewModel {
|
viewModel {
|
||||||
ControladorViewModel()
|
ControladorViewModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewModel {
|
||||||
|
ParkingViewModel()
|
||||||
|
}
|
||||||
|
|
||||||
|
viewModel {
|
||||||
|
PreSacadorViewModel()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -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.101:8009/"
|
//const val BASE_URL:String = "http://192.168.1.104: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()
|
||||||
|
|
|
@ -7,5 +7,6 @@ object ConstAndValues {
|
||||||
const val PREPARED = "PREPARED"
|
const val PREPARED = "PREPARED"
|
||||||
const val ON_PREPARATION = "ON_PREPARATION"
|
const val ON_PREPARATION = "ON_PREPARATION"
|
||||||
const val CHECKED = "CHECKED"
|
const val CHECKED = "CHECKED"
|
||||||
|
const val PRESACADOR = "PRESACADOR"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package es.verdnatura.domain
|
||||||
|
|
||||||
|
import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO
|
||||||
|
import retrofit2.Call
|
||||||
|
|
||||||
|
class GetPreSacadorUseCase() : RestClient() {
|
||||||
|
|
||||||
|
fun ticketToPrePrepare(usuario:String,password:String,ticketFk:String,sectorFk:String) : Call<List<PreSacadorItemVO>> {
|
||||||
|
val params:ArrayList<String> = ArrayList();
|
||||||
|
params.add(ticketFk)
|
||||||
|
params.add(sectorFk)
|
||||||
|
return restClient!!.ticketToPrePrepare("json","1",usuario,password,"application/json",params)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ 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.presacador.model.PreSacadorItemVO
|
||||||
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.PlacementSupplyVO
|
||||||
import es.verdnatura.presentation.view.feature.sacador.model.PlacementVO
|
import es.verdnatura.presentation.view.feature.sacador.model.PlacementVO
|
||||||
|
@ -52,6 +53,18 @@ interface VerdnaturaService {
|
||||||
@Header("pass") pass: String,
|
@Header("pass") pass: String,
|
||||||
@Header("Content-Type") content_type: String):
|
@Header("Content-Type") content_type: String):
|
||||||
Call<List<SectorItemVO>>
|
Call<List<SectorItemVO>>
|
||||||
|
//PRESACADORES ========================================================================>
|
||||||
|
|
||||||
|
@POST("almacennew/ticketToPrePrepare")
|
||||||
|
fun ticketToPrePrepare(@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<PreSacadorItemVO>>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//SACADORES / CONTROLADORES ========================================================================>
|
//SACADORES / CONTROLADORES ========================================================================>
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package es.verdnatura.presentation.common
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import android.view.View.GONE
|
||||||
|
import android.view.View.VISIBLE
|
||||||
|
import androidx.databinding.BindingAdapter
|
||||||
|
import org.koin.core.KoinComponent
|
||||||
|
|
||||||
|
object BindingAdapter : KoinComponent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set view visibility depending boolean
|
||||||
|
*
|
||||||
|
* @param isVisible - If true, set view to VISIBLE, else set view to GONE
|
||||||
|
*/
|
||||||
|
@BindingAdapter("isVisible")
|
||||||
|
@JvmStatic
|
||||||
|
fun View.isVisible(isVisible: Boolean) {
|
||||||
|
visibility = if (isVisible) VISIBLE else GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -32,6 +32,10 @@ class PlacementAdapter (
|
||||||
) : RecyclerView.ViewHolder(binding.root){
|
) : RecyclerView.ViewHolder(binding.root){
|
||||||
fun bind(placement: PlacementVO) {
|
fun bind(placement: PlacementVO) {
|
||||||
binding.apply {
|
binding.apply {
|
||||||
|
if (placement.placement.isNullOrEmpty())
|
||||||
|
placement.placement = placement.parking
|
||||||
|
if (placement.visible.isNullOrEmpty())
|
||||||
|
placement.visible = "("+placement.stockTotal+")"
|
||||||
this.item = placement
|
this.item = placement
|
||||||
itemRootLayout.setOnClickListener {
|
itemRootLayout.setOnClickListener {
|
||||||
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Ubicador"),placement.shelving)
|
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Ubicador"),placement.shelving)
|
||||||
|
|
|
@ -248,6 +248,7 @@ class CollectionFragment(
|
||||||
onQuantityOfShelvingSelected(itemShelvingFkStored)
|
onQuantityOfShelvingSelected(itemShelvingFkStored)
|
||||||
}else{
|
}else{
|
||||||
customDialogList.setValueTwo("")
|
customDialogList.setValueTwo("")
|
||||||
|
showErrorMessage("El resultado del procedimiento barcodeToItem de la etiqueta escaneada es: " +it.response)
|
||||||
mperror?.start()
|
mperror?.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1066,6 +1067,12 @@ class CollectionFragment(
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showErrorMessage(text:String){
|
||||||
|
customDialog.setTitle("Error al marcar la linea").setDescription(text).setKoButton("Cerrar"){
|
||||||
|
customDialog.dismiss()
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,10 @@ import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionSc
|
||||||
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionTruckListFragment
|
import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionTruckListFragment
|
||||||
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckVO
|
import es.verdnatura.presentation.view.feature.paletizador.model.ItemExpeditionTruckVO
|
||||||
import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletVO
|
import es.verdnatura.presentation.view.feature.paletizador.model.ItemPalletVO
|
||||||
|
import es.verdnatura.presentation.view.feature.parking.fragment.ParkingFragment
|
||||||
import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroFragment
|
import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroFragment
|
||||||
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.presacador.fragment.PreSacadorFragment
|
||||||
import es.verdnatura.presentation.view.feature.sacador.fragment.SacadorFragment
|
import es.verdnatura.presentation.view.feature.sacador.fragment.SacadorFragment
|
||||||
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
|
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
|
||||||
import es.verdnatura.presentation.view.feature.shelvingparking.fragment.ShelvingParkingFragment
|
import es.verdnatura.presentation.view.feature.shelvingparking.fragment.ShelvingParkingFragment
|
||||||
|
@ -163,9 +165,16 @@ class MainActivity : BaseActivity<ActivityMainBinding>() , OnPasillerosItemClick
|
||||||
|
|
||||||
override fun onPasillerosItemClickListener(item: PasillerosItemVO, entryPoint: String) {
|
override fun onPasillerosItemClickListener(item: PasillerosItemVO, entryPoint: String) {
|
||||||
when (item.title){
|
when (item.title){
|
||||||
|
|
||||||
|
"Pre Sacador" -> {
|
||||||
|
addFragmentOnTop(PreSacadorFragment.newInstance())
|
||||||
|
}
|
||||||
"Consultar artículo" -> {
|
"Consultar artículo" -> {
|
||||||
addFragmentOnTop(ItemCardFragment.newInstance(entryPoint))
|
addFragmentOnTop(ItemCardFragment.newInstance(entryPoint))
|
||||||
}
|
}
|
||||||
|
"Parking" -> {
|
||||||
|
addFragmentOnTop(ParkingFragment.newInstance())
|
||||||
|
}
|
||||||
"Buscar item" -> {
|
"Buscar item" -> {
|
||||||
addFragmentOnTop(BuscarItemFragment.newInstance(entryPoint))
|
addFragmentOnTop(BuscarItemFragment.newInstance(entryPoint))
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.parking.adapter
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import es.verdnatura.databinding.ItemBarcodeRowBinding
|
||||||
|
import es.verdnatura.presentation.common.OnBarcodeRowClickListener
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
|
||||||
|
|
||||||
|
|
||||||
|
class ParkingAdapter (
|
||||||
|
private val items: List<BarcodeVO>,
|
||||||
|
private val onBarcodeRowClickListener: OnBarcodeRowClickListener
|
||||||
|
): RecyclerView.Adapter<ParkingAdapter.ItemHolder> () {
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder {
|
||||||
|
return ItemHolder(
|
||||||
|
ItemBarcodeRowBinding.inflate(LayoutInflater.from(parent.context),parent,false)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() =items.size
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ItemHolder, position: Int) {
|
||||||
|
holder.bind(items[position])
|
||||||
|
holder.binding.root.setOnClickListener {
|
||||||
|
onBarcodeRowClickListener.onBarcodeRowClickListener(items[position])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inner class ItemHolder(
|
||||||
|
val binding: ItemBarcodeRowBinding
|
||||||
|
) : RecyclerView.ViewHolder(binding.root){
|
||||||
|
fun bind(item: BarcodeVO) {
|
||||||
|
binding.apply {
|
||||||
|
this.item = item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,146 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.parking.fragment
|
||||||
|
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.media.MediaPlayer
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import android.view.inputmethod.EditorInfo
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import es.verdnatura.R
|
||||||
|
import es.verdnatura.databinding.FragmentParkingBinding
|
||||||
|
import es.verdnatura.presentation.base.BaseFragment
|
||||||
|
import es.verdnatura.presentation.common.OnBarcodeRowClickListener
|
||||||
|
import es.verdnatura.presentation.common.hideKeyboard
|
||||||
|
import es.verdnatura.presentation.view.component.CustomDialog
|
||||||
|
import es.verdnatura.presentation.view.feature.articulo.model.BarcodeVO
|
||||||
|
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
||||||
|
import es.verdnatura.presentation.view.feature.parking.adapter.ParkingAdapter
|
||||||
|
import kotlinx.android.synthetic.main.fragment_parking.*
|
||||||
|
import kotlinx.android.synthetic.main.toolbar.*
|
||||||
|
|
||||||
|
class ParkingFragment : BaseFragment<FragmentParkingBinding,ParkingViewModel>(ParkingViewModel::class) {
|
||||||
|
|
||||||
|
private var user = ""
|
||||||
|
private var password = ""
|
||||||
|
private var sectorFk = ""
|
||||||
|
private var warehouseFk = ""
|
||||||
|
private lateinit var customDialog: CustomDialog
|
||||||
|
private var scanerList:ArrayList<BarcodeVO> = ArrayList()
|
||||||
|
private var adapter : ParkingAdapter? = null
|
||||||
|
private var numParking : Int = 0
|
||||||
|
var mperror: MediaPlayer? = null
|
||||||
|
var mpok: MediaPlayer? = null
|
||||||
|
|
||||||
|
|
||||||
|
override fun getLayoutId(): Int = R.layout.fragment_parking
|
||||||
|
companion object {
|
||||||
|
fun newInstance() = ParkingFragment()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun init() {
|
||||||
|
setEvents()
|
||||||
|
toolbar_title.text = "Parking"
|
||||||
|
viewModel.hideProgressLoading()
|
||||||
|
setList()
|
||||||
|
customDialog = CustomDialog(requireContext())
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setEvents(){
|
||||||
|
scan_input.requestFocus()
|
||||||
|
scan_input.setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
|
||||||
|
if (!scan_input.text.isNullOrEmpty()) {
|
||||||
|
checkScan(scan_input.text.toString())
|
||||||
|
}
|
||||||
|
scan_input.setText("")
|
||||||
|
requireActivity().hideKeyboard()
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
backButton.setOnClickListener {
|
||||||
|
activity!!.onBackPressed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun observeViewModel() {
|
||||||
|
with(viewModel){
|
||||||
|
response.observe(viewLifecycleOwner, Observer {
|
||||||
|
if (it.isError){
|
||||||
|
mperror?.start()
|
||||||
|
splash_progress.visibility = View.GONE
|
||||||
|
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
|
||||||
|
customDialog.hide()
|
||||||
|
}.show()
|
||||||
|
}else{
|
||||||
|
numParking -= 1
|
||||||
|
if (numParking <= 0) {
|
||||||
|
splash_progress.visibility = View.GONE
|
||||||
|
viewModel.hideProgressLoading()
|
||||||
|
mpok?.start()
|
||||||
|
setList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setList(){
|
||||||
|
scanerList = ArrayList()
|
||||||
|
adapter = ParkingAdapter(scanerList,object: OnBarcodeRowClickListener{
|
||||||
|
override fun onBarcodeRowClickListener(item: BarcodeVO) {
|
||||||
|
scanerList.removeAt(scanerList.indexOf(item))
|
||||||
|
adapter?.notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
val lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||||
|
|
||||||
|
fragment_parking_scan_list.adapter = adapter
|
||||||
|
fragment_parking_scan_list.layoutManager = lm
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkScan(txtScan:String){
|
||||||
|
var isParking:Boolean = false
|
||||||
|
if (txtScan.trim().length == 4 && isLetter(txtScan.substring(txtScan.length - 1)) || txtScan.contains("-")){
|
||||||
|
isParking = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isParking){
|
||||||
|
numParking = scanerList.size
|
||||||
|
scanerList.forEach {
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
viewModel.parking(
|
||||||
|
usuario = user,
|
||||||
|
password = password,
|
||||||
|
parking = txtScan,
|
||||||
|
scanItem = it.code!!
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
scanerList.add(BarcodeVO(code = txtScan))
|
||||||
|
adapter?.notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0)
|
||||||
|
user = prefs.getString(USER,"").toString()
|
||||||
|
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)
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Throws(NumberFormatException::class)
|
||||||
|
fun isLetter(text: String): Boolean {
|
||||||
|
return text.matches("[a-zA-Z ]+".toRegex())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.parking.fragment
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import es.verdnatura.domain.GetUbicadorUserCase
|
||||||
|
import es.verdnatura.presentation.base.BaseViewModel
|
||||||
|
import es.verdnatura.presentation.common.ResponseItemVO
|
||||||
|
import retrofit2.Call
|
||||||
|
import retrofit2.Callback
|
||||||
|
import retrofit2.Response
|
||||||
|
|
||||||
|
class ParkingViewModel : BaseViewModel() {
|
||||||
|
private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase()
|
||||||
|
|
||||||
|
private val _response by lazy { MutableLiveData<ResponseItemVO>() }
|
||||||
|
val response: LiveData<ResponseItemVO>
|
||||||
|
get() = _response
|
||||||
|
|
||||||
|
private val _isLoading by lazy { MutableLiveData<Boolean>() }
|
||||||
|
val isLoading: LiveData<Boolean> = _isLoading
|
||||||
|
|
||||||
|
private fun showProgressLoading() {
|
||||||
|
_isLoading.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun hideProgressLoading() {
|
||||||
|
_isLoading.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun parking(usuario: String,password: String,scanItem: String,parking:String){
|
||||||
|
showProgressLoading()
|
||||||
|
getUbicadorUserCase.shelvingPark(usuario,password,scanItem,parking).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 shelvingPark")
|
||||||
|
}else{
|
||||||
|
if (response.body() == "Finish")
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
else
|
||||||
|
_response.value = ResponseItemVO(isError = true,errorMessage = "No existe el parking en la Base de Datos (shelvingPark)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -12,12 +12,25 @@ class PasilleroViewModel : BaseViewModel() {
|
||||||
|
|
||||||
|
|
||||||
fun inititializeDefaultData() {
|
fun inititializeDefaultData() {
|
||||||
|
|
||||||
|
_pasillerositem.add(
|
||||||
|
PasillerosItemVO(7,
|
||||||
|
R.drawable.ic_streetview_black_24dp,
|
||||||
|
"Pre Sacador")
|
||||||
|
)
|
||||||
|
|
||||||
_pasillerositem.add(
|
_pasillerositem.add(
|
||||||
PasillerosItemVO(0,
|
PasillerosItemVO(0,
|
||||||
R.drawable.ic_loyalty_black_24dp,
|
R.drawable.ic_loyalty_black_24dp,
|
||||||
"Consultar artículo")
|
"Consultar artículo")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_pasillerositem.add(
|
||||||
|
PasillerosItemVO(6,
|
||||||
|
R.drawable.ic_local_parking_orange_24dp,
|
||||||
|
"Parking")
|
||||||
|
)
|
||||||
|
|
||||||
_pasillerositem.add(
|
_pasillerositem.add(
|
||||||
PasillerosItemVO(2,
|
PasillerosItemVO(2,
|
||||||
R.drawable.ic_visibility_black_24dp,
|
R.drawable.ic_visibility_black_24dp,
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.presacador.adapter
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
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.common.OnQuantityClickListener
|
||||||
|
import es.verdnatura.presentation.common.OnSaleClickListener
|
||||||
|
import es.verdnatura.presentation.view.feature.collection.adapter.PlacementAdapter
|
||||||
|
import es.verdnatura.presentation.view.feature.collection.adapter.SaleAdapter
|
||||||
|
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.presacador.mapper.toSale
|
||||||
|
import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.SaleVO
|
||||||
|
|
||||||
|
class PreSacadorAdapter (
|
||||||
|
private val items: List<PreSacadorItemVO>,
|
||||||
|
private val onPasillerosItemClickListener: OnPasillerosItemClickListener,
|
||||||
|
private val onSaleClickListener: OnSaleClickListener
|
||||||
|
): RecyclerView.Adapter<PreSacadorAdapter.AjustesItemHolder> () {
|
||||||
|
var context: Context? = null
|
||||||
|
var position:Int = 0
|
||||||
|
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) {
|
||||||
|
this.position = position
|
||||||
|
holder.bind(items[position])
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class AjustesItemHolder(
|
||||||
|
val binding: ItemArticleRowBinding
|
||||||
|
) : RecyclerView.ViewHolder(binding.root){
|
||||||
|
fun bind(preSale: PreSacadorItemVO) {
|
||||||
|
binding.apply {
|
||||||
|
|
||||||
|
val sale : SaleVO = preSale.toSale()
|
||||||
|
|
||||||
|
if (sale.pickedQuantity.isNullOrEmpty())
|
||||||
|
sale.pickedQuantity = "0"
|
||||||
|
|
||||||
|
val childLayoutManager = LinearLayoutManager(context!!, RecyclerView.HORIZONTAL, false)
|
||||||
|
|
||||||
|
itemArticlePlacements.apply {
|
||||||
|
layoutManager = childLayoutManager
|
||||||
|
adapter = PlacementAdapter(sale.placements,onPasillerosItemClickListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
//CLICK EVENTS
|
||||||
|
contentLayout.setOnClickListener {
|
||||||
|
onSaleClickListener.onSaleClick(sale)
|
||||||
|
}
|
||||||
|
|
||||||
|
itemArticleItemFk.setOnClickListener {
|
||||||
|
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Consultar artículo"),sale.itemFk)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//SEMAFORO
|
||||||
|
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.isPreviousPrepared == "1"){
|
||||||
|
contentLayout.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_dark_sky_blue))
|
||||||
|
}else{
|
||||||
|
contentLayout.setBackgroundColor(ContextCompat.getColor(context!!, R.color.verdnatura_black))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//ASIGNAMOS VALOR A LA VSITA
|
||||||
|
this.sale = sale
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,621 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.presacador.fragment
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.media.MediaPlayer
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import android.view.inputmethod.EditorInfo
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import es.verdnatura.R
|
||||||
|
import es.verdnatura.databinding.FragmentPreSacadorBinding
|
||||||
|
import es.verdnatura.domain.toast
|
||||||
|
import es.verdnatura.presentation.base.BaseFragment
|
||||||
|
import es.verdnatura.presentation.common.*
|
||||||
|
import es.verdnatura.presentation.view.component.CustomDialog
|
||||||
|
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.inventario.adapter.ToolBarAdapter
|
||||||
|
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
|
||||||
|
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.presacador.adapter.PreSacadorAdapter
|
||||||
|
import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO
|
||||||
|
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_pre_sacador.*
|
||||||
|
import kotlinx.android.synthetic.main.toolbar.*
|
||||||
|
import es.verdnatura.domain.ConstAndValues.PRESACADOR
|
||||||
|
import es.verdnatura.presentation.view.component.CustomDialogInput
|
||||||
|
|
||||||
|
class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorViewModel>(PreSacadorViewModel::class) {
|
||||||
|
private var user = ""
|
||||||
|
private var password = ""
|
||||||
|
private var sectorFk = ""
|
||||||
|
private var warehouseFk = ""
|
||||||
|
var mperror: MediaPlayer? = null
|
||||||
|
var mpok: MediaPlayer? = null
|
||||||
|
private var sales:ArrayList<PreSacadorItemVO> = ArrayList()
|
||||||
|
private lateinit var customDialog: CustomDialog
|
||||||
|
private lateinit var customDialogList: CustomDialogList
|
||||||
|
private var saleAdapter: PreSacadorAdapter? = null
|
||||||
|
private var ticket:String = ""
|
||||||
|
private var lm : LinearLayoutManager? = null
|
||||||
|
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
|
||||||
|
private var storedPosition: Int = 0
|
||||||
|
private var storedBackPosition : Int = 0
|
||||||
|
private var storedShelvingPosition:Int = 0
|
||||||
|
private var itemShelvingFkStored : String = ""
|
||||||
|
private var goBack:Boolean = false
|
||||||
|
private var goBack2:Boolean = false
|
||||||
|
private var listPlacementSupply:ArrayList<BarcodeVO> = ArrayList()
|
||||||
|
private var placementSupplyAdapter : BarcodeAdapter? = null
|
||||||
|
private lateinit var customDialogInput: CustomDialogInput
|
||||||
|
|
||||||
|
override fun onAttach(context: Context) {
|
||||||
|
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
|
||||||
|
super.onAttach(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
val prefs: SharedPreferences = activity!!.getSharedPreferences(PREFS_USER,0)
|
||||||
|
user = prefs.getString(USER,"").toString()
|
||||||
|
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)
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun init() {
|
||||||
|
customDialog = CustomDialog(requireContext())
|
||||||
|
customDialogList = CustomDialogList(requireContext())
|
||||||
|
customDialogInput = CustomDialogInput(requireContext())
|
||||||
|
activity!!.main_bottom_navigation.visibility = View.GONE
|
||||||
|
splash_progress.visibility = View.GONE
|
||||||
|
toolbar_title.text = "ticketToPrePrepare"
|
||||||
|
setToolBar()
|
||||||
|
setEvents()
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setEvents(){
|
||||||
|
backButton.setOnClickListener {
|
||||||
|
activity!!.onBackPressed()
|
||||||
|
}
|
||||||
|
//ESCANER =========
|
||||||
|
hideKeyboards()
|
||||||
|
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()){
|
||||||
|
if (scan_input.text.contains("-")){
|
||||||
|
//es parking
|
||||||
|
parkingTicket(scan_input.text.toString())
|
||||||
|
}else{
|
||||||
|
if (scan_input.text.length > 6){
|
||||||
|
//es ticket
|
||||||
|
searchTicket(scan_input.text.toString())
|
||||||
|
}else{
|
||||||
|
//es sale
|
||||||
|
findSale(scan_input.text.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
scan_input.setText("")
|
||||||
|
hideKeyboards()
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
hideKeyboards()
|
||||||
|
|
||||||
|
//LISTA =========
|
||||||
|
collection_swipe.setOnRefreshListener {
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
searchTicket(ticket)
|
||||||
|
collection_swipe.isRefreshing = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun observeViewModel() {
|
||||||
|
with(viewModel){
|
||||||
|
salesList.observe(viewLifecycleOwner, Observer {
|
||||||
|
splash_progress.visibility = View.GONE
|
||||||
|
createSaleList(it)
|
||||||
|
})
|
||||||
|
|
||||||
|
placementSuppleyList.observe(viewLifecycleOwner, Observer {
|
||||||
|
splash_progress.visibility = View.GONE
|
||||||
|
if (!goBack) printShelvingResult(it)
|
||||||
|
goBack = false
|
||||||
|
})
|
||||||
|
|
||||||
|
responseCode.observe(viewLifecycleOwner, Observer {
|
||||||
|
splash_progress.visibility = View.GONE
|
||||||
|
if (!goBack2){
|
||||||
|
if (it.isError){
|
||||||
|
customDialog.setTitle("Error").setDescription(it.errorMessage).setKoButton("Cerrar"){
|
||||||
|
scanRequest()
|
||||||
|
customDialog.dismiss()
|
||||||
|
}.show()
|
||||||
|
}else{
|
||||||
|
if (checkItemScan(it.response)){
|
||||||
|
scanRequest()
|
||||||
|
customDialogList.dismiss()
|
||||||
|
mpok?.start()
|
||||||
|
onQuantityOfShelvingSelected(itemShelvingFkStored)
|
||||||
|
}else{
|
||||||
|
customDialogList.setValueTwo("")
|
||||||
|
showErrorMessage("El resultado del procedimiento barcodeToItem de la etiqueta escaneada es: " +it.response)
|
||||||
|
mperror?.start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
goBack2 = false
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//CREATE LIST
|
||||||
|
private fun searchTicket(ticketFk:String){
|
||||||
|
ticket = ticketFk
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
viewModel.ticketToPrePrepare(
|
||||||
|
usuario = user,
|
||||||
|
password = password,
|
||||||
|
ticketFk = ticketFk,
|
||||||
|
sectorFk = sectorFk
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createSaleList(salesList : List<PreSacadorItemVO>){
|
||||||
|
splash_progress.visibility = View.GONE
|
||||||
|
if (salesList.isNullOrEmpty()){
|
||||||
|
customDialog.setTitle("Pre Sacador").setDescription("No hemos podido obtener movimientos para el ticket escaneado").setKoButton("Cancelar"){
|
||||||
|
customDialog.dismiss()
|
||||||
|
}.show()
|
||||||
|
}else{
|
||||||
|
toolbar_title.text = ticket
|
||||||
|
sales = ArrayList()
|
||||||
|
salesList.forEach {
|
||||||
|
sales.add(it)
|
||||||
|
}
|
||||||
|
lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
|
||||||
|
|
||||||
|
saleAdapter = PreSacadorAdapter(sales,pasillerosItemClickListener!!,object :
|
||||||
|
OnSaleClickListener {
|
||||||
|
override fun onSaleClick(sale: SaleVO) {
|
||||||
|
sales.forEachIndexed { index, saleVO ->
|
||||||
|
if (saleVO.idMovimiento == sale.saleFk) {
|
||||||
|
if (saleVO.quantity != saleVO.picked) {
|
||||||
|
showScanner(index, saleVO)
|
||||||
|
} else {
|
||||||
|
unMarkLine(index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
fragment_sacador_collections.adapter = saleAdapter
|
||||||
|
fragment_sacador_collections.layoutManager = lm
|
||||||
|
|
||||||
|
setTotalLines()
|
||||||
|
if (storedPosition != 0)
|
||||||
|
setListPosition(storedPosition)
|
||||||
|
else if (storedBackPosition != 0)
|
||||||
|
setListPosition(storedBackPosition)
|
||||||
|
|
||||||
|
setScrollListener(lm!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setScrollListener(lm: LinearLayoutManager){
|
||||||
|
fragment_sacador_collections.addOnScrollListener(object : RecyclerView.OnScrollListener(){
|
||||||
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
|
storedBackPosition = lm.findFirstVisibleItemPosition()
|
||||||
|
super.onScrolled(recyclerView, dx, dy)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setTotalLines(){
|
||||||
|
var totalMark = 0
|
||||||
|
sales.forEach {
|
||||||
|
if (it.quantity == it.picked)
|
||||||
|
totalMark += 1
|
||||||
|
}
|
||||||
|
toolbar_title.text = ticket
|
||||||
|
toolbar_subtitle.text = "" +totalMark + "/" + sales.size
|
||||||
|
if (totalMark == sales.size) {
|
||||||
|
"Ticket completo".toast(this.context, Toast.LENGTH_SHORT)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setListPosition(position:Int){
|
||||||
|
storedPosition = position
|
||||||
|
fragment_sacador_collections.addViewObserver {
|
||||||
|
lm!!.scrollToPositionWithOffset(position,0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//SEARCH AND MARK
|
||||||
|
private fun findSale(txtscan:String){
|
||||||
|
var index = 0
|
||||||
|
var isBreak = false
|
||||||
|
var isOk = false
|
||||||
|
|
||||||
|
for (saleVO in sales) {
|
||||||
|
if(saleVO.quantity != saleVO.picked){
|
||||||
|
//1- Por carro
|
||||||
|
var shelvingIndex = 0
|
||||||
|
for (placementVO in saleVO.carros){
|
||||||
|
if (txtscan.toUpperCase() == placementVO.shelving.toUpperCase()){
|
||||||
|
mpok!!.start()
|
||||||
|
isOk = true
|
||||||
|
showShelving(index,shelvingIndex)
|
||||||
|
isBreak = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
shelvingIndex+=1
|
||||||
|
}
|
||||||
|
if (isBreak) break
|
||||||
|
}
|
||||||
|
index += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isOk) {
|
||||||
|
mperror!!.start()
|
||||||
|
("Elemento escaneado no encontrado: "+txtscan).toast(requireContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun findSale(txtscan:String,position: Int){
|
||||||
|
var index = 0
|
||||||
|
var isBreak = false
|
||||||
|
var isOk = false
|
||||||
|
|
||||||
|
val saleVO = sales[position]
|
||||||
|
|
||||||
|
if(saleVO.quantity != saleVO.picked){
|
||||||
|
//1- Por carro
|
||||||
|
var shelvingIndex = 0
|
||||||
|
for (placementVO in saleVO.carros){
|
||||||
|
if (txtscan.toUpperCase() == placementVO.shelving.toUpperCase()){
|
||||||
|
mpok!!.start()
|
||||||
|
isOk = true
|
||||||
|
showShelving(position,shelvingIndex)
|
||||||
|
isBreak = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
shelvingIndex+=1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
index += 1
|
||||||
|
|
||||||
|
|
||||||
|
if (!isOk) {
|
||||||
|
mperror!!.start()
|
||||||
|
("Elemento escaneado no encontrado: "+txtscan).toast(requireContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun markLine(position:Int){
|
||||||
|
|
||||||
|
saleAdapter!!.notifyDataSetChanged()
|
||||||
|
setListPosition(position)
|
||||||
|
saleTrackingReplace(position)
|
||||||
|
setTotalLines()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun saleTrackingReplace(position: Int){
|
||||||
|
viewModel.saleTrackingReplace(
|
||||||
|
usuario = user,
|
||||||
|
password = password,
|
||||||
|
saleFk = sales[position].idMovimiento,
|
||||||
|
vIsChecked = if (sales[position].picked == sales[position].quantity) "1" else "0",
|
||||||
|
vOriginalQuantity = sales[position].picked.toString(),
|
||||||
|
vStateFk = PRESACADOR
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun unMarkLine(position: Int){
|
||||||
|
|
||||||
|
if (sales[position].quantity == sales[position].picked){
|
||||||
|
customDialog.setTitle("Desmarcar linea").setDescription("Vas a desmarcar la linea: "+sales[position].itemFk+ " ¿Estás seguro?").setOkButton("Desmarcar"){
|
||||||
|
sales[position].picked = 0
|
||||||
|
saleAdapter!!.notifyDataSetChanged()
|
||||||
|
setListPosition(position)
|
||||||
|
viewModel.saleTrackingDel(
|
||||||
|
usuario = user,
|
||||||
|
password = password,
|
||||||
|
saleFk = sales[position].idMovimiento
|
||||||
|
)
|
||||||
|
setTotalLines()
|
||||||
|
scanRequest()
|
||||||
|
customDialog.dismiss()
|
||||||
|
}.setKoButton("Cancelar"){
|
||||||
|
scanRequest()
|
||||||
|
customDialog.dismiss()
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//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 - sales[position].picked).toString()
|
||||||
|
}catch (e:Exception){}
|
||||||
|
viewModel.itemPlacementSupplyAiming(
|
||||||
|
usuario = user,
|
||||||
|
password = password,
|
||||||
|
itemFk = sales[position].itemFk,
|
||||||
|
quantity = quantityGet,
|
||||||
|
shelvingFk = sales[position].carros[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"){
|
||||||
|
if (customDialogList.getValueTwo().isNotEmpty()){
|
||||||
|
if (checkItemScan(customDialogList.getValueTwo())){
|
||||||
|
onQuantityOfShelvingSelected(itemShelvingFk)
|
||||||
|
mpok?.start()
|
||||||
|
customDialogList.dismiss()
|
||||||
|
}else{
|
||||||
|
itemShelvingFkStored = itemShelvingFk
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
viewModel.getIdFromCode(
|
||||||
|
usuario = user,
|
||||||
|
password = password,
|
||||||
|
code = customDialogList.getValueTwo()
|
||||||
|
)
|
||||||
|
customDialogList.dismiss()
|
||||||
|
}
|
||||||
|
scanRequest()
|
||||||
|
hideKeyboards()
|
||||||
|
}else{
|
||||||
|
"Escanea item para validar".toast(requireContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}.setKoButton("Cerrar"){
|
||||||
|
scanRequest()
|
||||||
|
hideKeyboards()
|
||||||
|
customDialogList.dismiss()
|
||||||
|
}.setHintValue("Cantidad que coges:").setValue(total).setHintValueTwo("Escanea item").setValueTwo("").show()
|
||||||
|
|
||||||
|
|
||||||
|
customDialogList.getEditTextTwo().post(Runnable {
|
||||||
|
customDialogList.getEditTextTwo().requestFocusFromTouch()
|
||||||
|
val lManager: InputMethodManager =
|
||||||
|
activity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
lManager.hideSoftInputFromWindow(customDialogList.getEditTextTwo().windowToken, InputMethodManager.SHOW_FORCED)
|
||||||
|
})
|
||||||
|
|
||||||
|
customDialogList.getEditTextTwo().setOnEditorActionListener { v, actionId, event ->
|
||||||
|
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0 || actionId == 5) {
|
||||||
|
if (customDialogList.getValueTwo().isNotEmpty()){
|
||||||
|
if (checkItemScan(customDialogList.getValueTwo())){
|
||||||
|
onQuantityOfShelvingSelected(itemShelvingFk)
|
||||||
|
mpok?.start()
|
||||||
|
customDialogList.dismiss()
|
||||||
|
}else{
|
||||||
|
itemShelvingFkStored = itemShelvingFk
|
||||||
|
splash_progress.visibility = View.VISIBLE
|
||||||
|
viewModel.getIdFromCode(
|
||||||
|
usuario = user,
|
||||||
|
password = password,
|
||||||
|
code = customDialogList.getValueTwo()
|
||||||
|
)
|
||||||
|
customDialogList.dismiss()
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
"Escanea item para validar".toast(requireContext())
|
||||||
|
}
|
||||||
|
scanRequest()
|
||||||
|
hideKeyboards()
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
|
||||||
|
}
|
||||||
|
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].carros[storedShelvingPosition].stockTotal
|
||||||
|
|
||||||
|
sales[storedPosition].carros[storedShelvingPosition].stockTotal = (shelvingVisible.toInt() - customDialogList.getValue().toInt()).toString()
|
||||||
|
|
||||||
|
viewModel.itemShelvingSaleSupplyAdd(
|
||||||
|
usuario = user,
|
||||||
|
password = password,
|
||||||
|
itemShelvingFk = itemShelvingFk,
|
||||||
|
saleFk = sales[storedPosition].idMovimiento,
|
||||||
|
quantity = customDialogList.getValue()
|
||||||
|
)
|
||||||
|
|
||||||
|
}catch (e:Exception){}
|
||||||
|
|
||||||
|
//2- MODIFICAR EL PICKED DEL SALE
|
||||||
|
try{
|
||||||
|
sales[storedPosition].picked = sales[storedPosition].picked + customDialogList.getValue().toInt()
|
||||||
|
}catch (e:Exception){}
|
||||||
|
|
||||||
|
//3- MARCAR LINEA
|
||||||
|
markLine(storedPosition)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkItemScan(valueToCheck:String):Boolean{
|
||||||
|
val saleToCheck = sales[storedPosition]
|
||||||
|
return saleToCheck.itemFk == valueToCheck
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showScanner(index:Int, sale:PreSacadorItemVO){
|
||||||
|
customDialogInput.setTitle(""+sale.itemFk).setDescription("Escanea el carro para el item seleccionado").setOkButton("Aceptar"){
|
||||||
|
if (!customDialogInput.getValue().isNullOrEmpty()) {
|
||||||
|
findSale(customDialogInput.getValue(),index)
|
||||||
|
}
|
||||||
|
customDialogInput.setValue("")
|
||||||
|
scanRequest()
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
hideKeyboards()
|
||||||
|
}.setKoButton("Cancelar"){
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
}.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()) {
|
||||||
|
findSale(customDialogInput.getValue(),index)
|
||||||
|
}
|
||||||
|
customDialogInput.setValue("")
|
||||||
|
scanRequest()
|
||||||
|
customDialogInput.dismiss()
|
||||||
|
hideKeyboards()
|
||||||
|
return@setOnEditorActionListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//OPTIONS
|
||||||
|
private fun print(){
|
||||||
|
viewModel.collectionStickerPrint(
|
||||||
|
usuario = user,
|
||||||
|
password = password,
|
||||||
|
collectionFk = ticket,
|
||||||
|
sectorFk = sectorFk
|
||||||
|
)
|
||||||
|
"Imprimiendo...".toast(requireContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
//OTROS
|
||||||
|
private fun setToolBar(){
|
||||||
|
toolbar_subtitle.visibility = View.VISIBLE
|
||||||
|
|
||||||
|
val listIcons:ArrayList<Drawable> = ArrayList()
|
||||||
|
val iconPrint : Drawable = resources.getDrawable(R.drawable.ic_print_black_24dp,resources.newTheme())
|
||||||
|
val iconParking : Drawable = resources.getDrawable(R.drawable.ic_local_parking_black_24dp,resources.newTheme())
|
||||||
|
val iconTransferir : Drawable = resources.getDrawable(R.drawable.ic_swap_horiz_black_24dp,resources.newTheme())
|
||||||
|
|
||||||
|
listIcons.add(iconPrint)
|
||||||
|
listIcons.add(iconParking)
|
||||||
|
listIcons.add(iconTransferir)
|
||||||
|
|
||||||
|
toolbar_icons.adapter = ToolBarAdapter(listIcons,object: OnOptionsSelectedListener {
|
||||||
|
override fun onOptionsItemSelected(item: Drawable) {
|
||||||
|
if (item == iconPrint){
|
||||||
|
print()
|
||||||
|
}else if (item == iconParking){
|
||||||
|
pasillerosItemClickListener?.onPasillerosItemClickListener(PasillerosItemVO(title = "Parking"),"")
|
||||||
|
}else if (item == iconTransferir){
|
||||||
|
"Transferir".toast(requireContext())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
toolbar_icons.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun scanRequest(){
|
||||||
|
scan_input.requestFocus()
|
||||||
|
hideKeyboards()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun hideKeyboards(){
|
||||||
|
requireActivity().hideKeyboard()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun parkingTicket(parking:String){
|
||||||
|
viewModel.parking(
|
||||||
|
usuario = user,
|
||||||
|
password = password,
|
||||||
|
ticketFk = ticket,
|
||||||
|
parking = parking
|
||||||
|
)
|
||||||
|
mpok!!.start()
|
||||||
|
"Ticket aparcado".toast(requireContext())
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance() = PreSacadorFragment()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getLayoutId(): Int = R.layout.fragment_pre_sacador
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
goBack = true
|
||||||
|
goBack2 = true
|
||||||
|
super.onPause()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showErrorMessage(text:String){
|
||||||
|
customDialog.setTitle("Error al marcar la linea").setDescription(text).setKoButton("Cerrar"){
|
||||||
|
customDialog.dismiss()
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,176 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.presacador.fragment
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import es.verdnatura.domain.GetPreSacadorUseCase
|
||||||
|
import es.verdnatura.domain.GetSacadorControladorUserCase
|
||||||
|
import es.verdnatura.domain.GetUbicadorUserCase
|
||||||
|
import es.verdnatura.presentation.base.BaseViewModel
|
||||||
|
import es.verdnatura.presentation.common.ResponseItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO
|
||||||
|
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
|
||||||
|
|
||||||
|
class PreSacadorViewModel : BaseViewModel() {
|
||||||
|
private val getPreSacadorUseCase: GetPreSacadorUseCase = GetPreSacadorUseCase()
|
||||||
|
private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase()
|
||||||
|
private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase()
|
||||||
|
|
||||||
|
private val _salesList by lazy { MutableLiveData<List<PreSacadorItemVO>>() }
|
||||||
|
val salesList: LiveData<List<PreSacadorItemVO>>
|
||||||
|
get() = _salesList
|
||||||
|
|
||||||
|
private val _response by lazy { MutableLiveData<ResponseItemVO>() }
|
||||||
|
val response: LiveData<ResponseItemVO>
|
||||||
|
get() = _response
|
||||||
|
|
||||||
|
private val _placementSuppleyList by lazy { MutableLiveData<PlacementSupplyListVO>() }
|
||||||
|
val placementSuppleyList: LiveData<PlacementSupplyListVO>
|
||||||
|
get() = _placementSuppleyList
|
||||||
|
|
||||||
|
private val _responseCode by lazy { MutableLiveData<ResponseItemVO>() }
|
||||||
|
val responseCode: LiveData<ResponseItemVO>
|
||||||
|
get() = _responseCode
|
||||||
|
|
||||||
|
|
||||||
|
fun ticketToPrePrepare(usuario:String,password:String,ticketFk:String,sectorFk:String){
|
||||||
|
getPreSacadorUseCase.ticketToPrePrepare(usuario,password,ticketFk,sectorFk).enqueue(object :
|
||||||
|
Callback<List<PreSacadorItemVO>> {
|
||||||
|
override fun onFailure(call: Call<List<PreSacadorItemVO>>, t: Throwable) {
|
||||||
|
_salesList.value = listOf()
|
||||||
|
}
|
||||||
|
override fun onResponse(
|
||||||
|
call: Call<List<PreSacadorItemVO>>,
|
||||||
|
response: Response<List<PreSacadorItemVO>>
|
||||||
|
) {
|
||||||
|
if (response.body() != null){
|
||||||
|
_salesList.value = response.body()?.let { it }
|
||||||
|
}else{
|
||||||
|
_salesList.value = listOf()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
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 parking(usuario: String,password: String,ticketFk: String,parking:String){
|
||||||
|
getUbicadorUserCase.shelvingPark(usuario,password,ticketFk,parking).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 shelvingPark")
|
||||||
|
}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 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 getIdFromCode(usuario:String,password:String,code: String){
|
||||||
|
getSacadorControladorUserCase.getIdFromCode(usuario,password,code).enqueue(object : Callback<String>{
|
||||||
|
override fun onFailure(call: Call<String>, t: Throwable) {
|
||||||
|
_responseCode.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResponse(call: Call<String>, response: Response<String>) {
|
||||||
|
if (response.body() == null){
|
||||||
|
_responseCode.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada barcodeToItem")
|
||||||
|
}else{
|
||||||
|
_responseCode.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun saleTrackingDel(usuario:String,password:String,saleFk: String){
|
||||||
|
getSacadorControladorUserCase.saleTrackingDel(usuario,password,saleFk).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 collectionMissingTrash")
|
||||||
|
}else{
|
||||||
|
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.presacador.mapper
|
||||||
|
|
||||||
|
import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.SaleVO
|
||||||
|
|
||||||
|
fun PreSacadorItemVO.toSale() : SaleVO {
|
||||||
|
return SaleVO(
|
||||||
|
ticketFk = id,
|
||||||
|
level = "1",
|
||||||
|
saleFk = idMovimiento,
|
||||||
|
itemFk = itemFk,
|
||||||
|
quantity = saldo.toString(),
|
||||||
|
longName = longName,
|
||||||
|
isPreviousPrepared = if (quantity == picked) "1" else "0",
|
||||||
|
line1 = longName,
|
||||||
|
line2 = if (subName.isNullOrEmpty()) "" else subName,
|
||||||
|
pickedQuantity = picked.toString(),
|
||||||
|
workerFk = trabajador,
|
||||||
|
originalQuantity = quantity.toString(),
|
||||||
|
placements = carros,
|
||||||
|
agencyName = trabajador
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package es.verdnatura.presentation.view.feature.presacador.model
|
||||||
|
|
||||||
|
import es.verdnatura.presentation.view.feature.sacador.model.PlacementVO
|
||||||
|
|
||||||
|
class PreSacadorItemVO (
|
||||||
|
var id : String = "",
|
||||||
|
var itemFk : String = "",
|
||||||
|
var longName : String = "",
|
||||||
|
var subName : String = "",
|
||||||
|
var quantity : Int = 0,
|
||||||
|
var saldo : Int = 0,
|
||||||
|
var picked : Int = 45,
|
||||||
|
var idMovimiento : String = "",
|
||||||
|
var trabajador : String = "",
|
||||||
|
var carros : List<PlacementVO> = listOf()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,8 @@ class PlacementVO(
|
||||||
var saleFk : String = "",
|
var saleFk : String = "",
|
||||||
var itemFk : String = "",
|
var itemFk : String = "",
|
||||||
var placement : String = "",
|
var placement : String = "",
|
||||||
|
var parking : String = "",
|
||||||
|
var stockTotal : String = "",
|
||||||
var shelving : String = "",
|
var shelving : String = "",
|
||||||
var created : String = "",
|
var created : String = "",
|
||||||
var visible : String = "",
|
var visible : String = "",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<vector android:height="24dp" android:tint="#FFFFFF"
|
<vector android:height="24dp" android:tint="#ffffff"
|
||||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<path android:fillColor="#FFFFFF" android:pathData="M13,3L6,3v18h4v-6h3c3.31,0 6,-2.69 6,-6s-2.69,-6 -6,-6zM13.2,11L10,11L10,7h3.2c1.1,0 2,0.9 2,2s-0.9,2 -2,2z"/>
|
<path android:fillColor="#ffffff" android:pathData="M13,3L6,3v18h4v-6h3c3.31,0 6,-2.69 6,-6s-2.69,-6 -6,-6zM13.2,11L10,11L10,7h3.2c1.1,0 2,0.9 2,2s-0.9,2 -2,2z"/>
|
||||||
</vector>
|
</vector>
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<vector android:height="24dp" android:tint="#F7931E"
|
||||||
|
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#F7931E" android:pathData="M13,3L6,3v18h4v-6h3c3.31,0 6,-2.69 6,-6s-2.69,-6 -6,-6zM13.2,11L10,11L10,7h3.2c1.1,0 2,0.9 2,2s-0.9,2 -2,2z"/>
|
||||||
|
</vector>
|
|
@ -0,0 +1,7 @@
|
||||||
|
<vector android:height="24dp" android:tint="#F7931E"
|
||||||
|
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#F7931E" android:pathData="M12.56,14.33c-0.34,0.27 -0.56,0.7 -0.56,1.17V21h7c1.1,0 2,-0.9 2,-2v-5.98c-0.94,-0.33 -1.95,-0.52 -3,-0.52 -2.03,0 -3.93,0.7 -5.44,1.83z"/>
|
||||||
|
<path android:fillColor="#F7931E" android:pathData="M18,6m-5,0a5,5 0,1 1,10 0a5,5 0,1 1,-10 0"/>
|
||||||
|
<path android:fillColor="#F7931E" android:pathData="M11.5,6c0,-1.08 0.27,-2.1 0.74,-3H5c-1.1,0 -2,0.9 -2,2v14c0,0.55 0.23,1.05 0.59,1.41l9.82,-9.82C12.23,9.42 11.5,7.8 11.5,6z"/>
|
||||||
|
</vector>
|
|
@ -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="M6.99,11L3,15l3.99,4v-3H14v-2H6.99v-3zM21,9l-3.99,-4v3H10v2h7.01v3L21,9z"/>
|
||||||
|
</vector>
|
|
@ -0,0 +1,97 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layout xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<data>
|
||||||
|
<variable
|
||||||
|
name="viewModel"
|
||||||
|
type="es.verdnatura.presentation.view.feature.parking.fragment.ParkingViewModel" />
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
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="textCapCharacters"
|
||||||
|
android:lines="1"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textColor="@color/verdnatura_white"
|
||||||
|
android:textColorHint="@android:color/darker_gray"
|
||||||
|
android:imeOptions="actionDone"/>
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/layout_margin_min"
|
||||||
|
android:layout_marginTop="@dimen/layout_margin_min"
|
||||||
|
android:layout_marginEnd="@dimen/layout_margin_min"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Primero escanea tantos carros o tickets como quieras aparcar y finalmente escanea el parking para finalizar el proceso"
|
||||||
|
android:textColor="@color/verdnatura_pumpkin_orange"
|
||||||
|
android:textSize="@dimen/body2"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/scan" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/fragment_parking_scan_list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_marginTop="@dimen/layout_margin_min"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textView"
|
||||||
|
tools:listitem="@layout/item_barcode_row" />
|
||||||
|
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/main_toolbar"
|
||||||
|
layout="@layout/toolbar"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/splash_progress"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="@color/verdnatura_black_8_alpha_6"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
android:gravity="center"
|
||||||
|
app:isVisible="@{viewModel.isLoading}">
|
||||||
|
|
||||||
|
<com.airbnb.lottie.LottieAnimationView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/verdnatura_logo_large_height"
|
||||||
|
app:lottie_autoPlay="true"
|
||||||
|
app:lottie_loop="true"
|
||||||
|
app:lottie_rawRes="@raw/orange_loading"
|
||||||
|
app:lottie_speed="2" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</layout>
|
|
@ -0,0 +1,86 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layout xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<data>
|
||||||
|
<variable
|
||||||
|
name="viewModel"
|
||||||
|
type="es.verdnatura.presentation.view.feature.presacador.fragment.PreSacadorViewModel" />
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/verdnatura_black">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/scan_input"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
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"
|
||||||
|
android:textSize="@dimen/body2"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/main_toolbar"
|
||||||
|
android:paddingLeft="@dimen/default_layout_margin"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
|
android:id="@+id/collection_swipe"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/scan_input">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/fragment_sacador_collections"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
tools:listitem="@layout/item_article_row" />
|
||||||
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/main_toolbar"
|
||||||
|
layout="@layout/toolbar"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/splash_progress"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="@color/verdnatura_black_8_alpha_6"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<com.airbnb.lottie.LottieAnimationView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/verdnatura_logo_large_height"
|
||||||
|
app:lottie_autoPlay="true"
|
||||||
|
app:lottie_loop="true"
|
||||||
|
app:lottie_rawRes="@raw/orange_loading"
|
||||||
|
app:lottie_speed="2" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</layout>
|
|
@ -70,13 +70,6 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
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
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
<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"
|
||||||
|
style="@style/LayoutClickable">
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
Loading…
Reference in New Issue