ubicador functions

This commit is contained in:
Enrique Blasco 2020-05-14 00:24:02 +02:00
parent d37a253ccc
commit 7d3da7c5b4
12 changed files with 357 additions and 15 deletions

View File

@ -11,7 +11,6 @@ class GetUbicadorUserCase : RestClient() {
fun itemShelvingList(usuario:String,password:String,vShelvingFk:String) : Call<List<ItemUbicadorVO>> {
val params:ArrayList<String> = ArrayList();
params.add(vShelvingFk)
return restClient!!.itemShelvingList("json","1",usuario,password,"application/json",params)!!
}
@ -24,7 +23,6 @@ class GetUbicadorUserCase : RestClient() {
params.add(packing)
params.add(warehouse)
params.add(level)
return restClient!!.itemShelvingMake("json","1",usuario,password,"application/json",params)!!
}
@ -35,9 +33,41 @@ class GetUbicadorUserCase : RestClient() {
params.add(deep)
params.add(warehouse)
params.add(level)
return restClient!!.itemShelvingMake_multi("json","1",usuario,password,"application/json",params)!!
}
fun shelvingPark(usuario:String,password:String,shelving:String,parking:String) : Call<String> {
val params:ArrayList<String> = ArrayList();
params.add(shelving)
params.add(parking)
return restClient!!.shelvingPark("json","1",usuario,password,"application/json",params)!!
}
fun shelvingChange(usuario:String,password:String,origen:String,destino:String) : Call<String> {
val params:ArrayList<String> = ArrayList();
params.add(origen)
params.add(destino)
return restClient!!.shelvingChange("json","1",usuario,password,"application/json",params)!!
}
fun clearShelvingList(usuario:String,password:String,shelvingFk:String) : Call<String> {
val params:ArrayList<String> = ArrayList();
params.add(shelvingFk)
return restClient!!.clearShelvingList("json","1",usuario,password,"application/json",params)!!
}
fun itemShelvingTransfer(usuario:String,password:String,itemFk:String,shelvingFk:String) : Call<String> {
val params:ArrayList<String> = ArrayList();
params.add(itemFk)
params.add(shelvingFk)
return restClient!!.itemShelvingTransfer("json","1",usuario,password,"application/json",params)!!
}
fun itemShelvingDelete(usuario:String,password:String,itemFk:String) : Call<String> {
val params:ArrayList<String> = ArrayList();
params.add(itemFk)
return restClient!!.itemShelvingDelete("json","1",usuario,password,"application/json",params)!!
}
}

View File

@ -191,5 +191,50 @@ interface VerdnaturaService {
@Body params: List<Any>):
Call<String>
@POST("almacenv2/shelvingPark")
fun shelvingPark(@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("almacenv2/shelvingChange")
fun shelvingChange(@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("almacenv2/clearShelvingList")
fun clearShelvingList(@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("almacenv2/itemShelvingTransfer")
fun itemShelvingTransfer(@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("almacenv2/itemShelvingDelete")
fun itemShelvingDelete(@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>
}

View File

@ -9,6 +9,7 @@ import es.verdnatura.presentation.view.feature.faltas.model.ItemFaltasVO
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.ubicador.model.ItemEscanerVO
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
interface OnOptionsSelectedListener {
fun onOptionsItemSelected(item: Drawable)
@ -50,3 +51,11 @@ interface OnFaltasReviewClickListener {
interface OnAutomaticItemClickListener {
fun onAutomaticItemClickListener(position: Int)
}
interface OnVisibleClickListener {
fun onVisibleClickListener(item: ItemUbicadorVO)
}
interface OnMoreClickListener {
fun onMoreClickListener(item: ItemUbicadorVO)
}

View File

@ -3,15 +3,23 @@ package es.verdnatura.presentation.view.feature.ubicador.adapter
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.R
import es.verdnatura.databinding.ItemShelvingparkingRowBinding
import es.verdnatura.databinding.ItemUbicationRowBinding
import es.verdnatura.presentation.common.OnMoreClickListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.common.OnVisibleClickListener
import es.verdnatura.presentation.common.loadUrl
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.shelvingparking.adapter.ShelvingParkingAdapter
import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
class UbicadorAdapter (
private val items: List<ItemUbicadorVO>
private val items: List<ItemUbicadorVO>,
private val onPasillerosItemClickListener: OnPasillerosItemClickListener,
private val onVisibleClickListener: OnVisibleClickListener,
private val onMoreClickListener: OnMoreClickListener
): RecyclerView.Adapter<UbicadorAdapter.ItemHolder> () {
@ -36,6 +44,23 @@ class UbicadorAdapter (
this.item = item
multiText.text = item.stickers+"x"+item.packing
imgItem.loadUrl("https://verdnatura.es/vn-image-data/catalog/200x200/"+item.item);
imgItem.setOnClickListener {
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Consultar artículo"),item.item)
}
layerVisible.setOnClickListener {
onVisibleClickListener.onVisibleClickListener(item)
}
if (item.visible == "0"){
visibleText.setTextColor(res.getColor(R.color.verdnatura_brown_grey))
}else{
visibleText.setTextColor(res.getColor(R.color.verdnatura_pumpkin_orange))
}
moreImg.setOnClickListener {
onMoreClickListener.onMoreClickListener(item)
}
}
}

View File

@ -1,7 +1,11 @@
package es.verdnatura.presentation.view.feature.ubicador.fragment
import android.app.Activity
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.widget.Toast
@ -12,23 +16,21 @@ import es.verdnatura.databinding.FragmentUbicadorBinding
import es.verdnatura.domain.notNull
import es.verdnatura.domain.toast
import es.verdnatura.presentation.base.BaseFragment
import es.verdnatura.presentation.common.OnMoreClickListener
import es.verdnatura.presentation.common.OnOptionsSelectedListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.common.OnVisibleClickListener
import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.component.CustomDialogInput
import es.verdnatura.presentation.view.component.CustomDialogTwoButtons
import es.verdnatura.presentation.view.component.CustomDialogUbicador
import es.verdnatura.presentation.view.feature.inventario.adapter.ToolBarAdapter
import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.shelvingparking.adapter.ShelvingParkingAdapter
import es.verdnatura.presentation.view.feature.ubicador.adapter.UbicadorAdapter
import es.verdnatura.presentation.view.feature.ubicador.model.ItemUbicadorVO
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.fragment_buscar_item.*
import kotlinx.android.synthetic.main.fragment_ubicador.*
import kotlinx.android.synthetic.main.fragment_ubicador.location_recyclerview
import kotlinx.android.synthetic.main.fragment_ubicador.splash_progress
import kotlinx.android.synthetic.main.toolbar.*
class UbicadorFragment(
@ -43,9 +45,15 @@ class UbicadorFragment(
private var adapter : UbicadorAdapter? = null
private lateinit var customDialogInput: CustomDialogInput
private lateinit var customDialogUbicador : CustomDialogUbicador
private lateinit var customDialogTwoButtons:CustomDialogTwoButtons
private var listItems:ArrayList<ItemUbicadorVO> = ArrayList()
private lateinit var customDialog: CustomDialog
private var deep:Int = 1
private var parking: String = ""
private var etiquetas:String = "0"
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
var mperror: MediaPlayer? = null
var mpok: MediaPlayer? = null
companion object {
@ -54,6 +62,10 @@ class UbicadorFragment(
override fun getLayoutId(): Int = R.layout.fragment_ubicador
override fun onAttach(context: Context) {
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
super.onAttach(context)
}
override fun init() {
@ -65,6 +77,7 @@ class UbicadorFragment(
customDialogInput = CustomDialogInput(requireContext())
customDialog = CustomDialog(requireContext())
customDialogUbicador = CustomDialogUbicador(requireContext())
customDialogTwoButtons = CustomDialogTwoButtons(requireContext())
activity!!.main_bottom_navigation.visibility = View.GONE
toolbar_title.text = "itemShelvingList"
setEvents()
@ -77,6 +90,12 @@ class UbicadorFragment(
super.init()
}
override fun onCreate(savedInstanceState: Bundle?) {
mperror = MediaPlayer.create((activity as MainActivity),R.raw.error)
mpok = MediaPlayer.create((activity as MainActivity),R.raw.ok)
super.onCreate(savedInstanceState)
}
private fun setToolBar(){
val listIcons:ArrayList<Drawable> = ArrayList()
val iconAdd : Drawable = resources.getDrawable(R.drawable.ic_add_black_24dp,resources.newTheme())
@ -86,7 +105,7 @@ class UbicadorFragment(
toolbar_icons.adapter = ToolBarAdapter(listIcons,object: OnOptionsSelectedListener {
override fun onOptionsItemSelected(item: Drawable) {
if (item == iconAdd){
showAddItem()
showAddItem("","","","")
}else if(item == iconReload){
splash_progress.visibility = View.VISIBLE
viewModel.itemShelvingList(user,password,shelvingFk)
@ -128,6 +147,78 @@ class UbicadorFragment(
"Escanea una matrícula".toast(activity!!,Toast.LENGTH_SHORT)
}
parking_img.setOnClickListener {
customDialogInput.setTitle("Aparcar carro").setValue("").setOkButton("Aparcar"){
viewModel.shelvingPark(user,password,shelvingFk,customDialogInput.getValue())
parking = customDialogInput.getValue()
toolbar_title.text = shelvingFk.toUpperCase() + " P: "+parking + " E: "+etiquetas
mpok!!.start()
customDialogInput.hide()
}.setKoButton("Cancelar"){
customDialogInput.hide()
}.show()
customDialogInput.getEditText().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
viewModel.shelvingPark(user,password,shelvingFk,customDialogInput.getValue())
customDialogInput.hide()
parking = customDialogInput.getValue()
toolbar_title.text = shelvingFk.toUpperCase() + " P: "+parking+ " E: "+etiquetas
mpok!!.start()
return@setOnEditorActionListener true
}
false
}
}
edit_img.setOnClickListener {
customDialogInput.setTitle("Cambiar matrícula").setValue("").setOkButton("Guardar"){
viewModel.shelvingChange(user,password,shelvingFk,customDialogInput.getValue())
shelvingFk = customDialogInput.getValue()
toolbar_title.text = shelvingFk.toUpperCase() + " P: "+parking+ " E: "+etiquetas
mpok!!.start()
customDialogInput.hide()
}.setKoButton("Cancelar"){
customDialogInput.hide()
}.show()
customDialogInput.getEditText().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
viewModel.shelvingChange(user,password,shelvingFk,customDialogInput.getValue())
customDialogInput.hide()
shelvingFk = customDialogInput.getValue()
toolbar_title.text = shelvingFk.toUpperCase() + " P: "+parking+ " E: "+etiquetas
mpok!!.start()
return@setOnEditorActionListener true
}
false
}
}
delete_img.setOnClickListener {
customDialog.setTitle("Vaciar carro").setDescription("Esta operación no se puede rectificar.").setOkButton("Vaciar"){
viewModel.clearShelvingList(user,password,shelvingFk)
listItems.forEach {
it.stickers = "0"
it.visible = "0"
}
adapter!!.notifyDataSetChanged()
customDialog.hide()
}.setKoButton("Cancelar"){
customDialog.hide()
}.show()
}
}
override fun observeViewModel() {
@ -136,19 +227,66 @@ class UbicadorFragment(
event.getContentIfNotHandled().notNull {
deep = it.list.size
listItems = ArrayList()
var contEtiquetas:Int = 0
it.list.forEach { item ->
contEtiquetas += item.stickers.toInt()
parking = item.code.toUpperCase()
listItems.add(item)
}
etiquetas = contEtiquetas.toString()
toolbar_title.text = shelvingFk.toUpperCase() + " P: "+parking+ " E: "+etiquetas
splash_progress.visibility = View.GONE
adapter = UbicadorAdapter(listItems)
adapter = UbicadorAdapter(listItems,onPasillerosItemClickListener = pasillerosItemClickListener!!,
onVisibleClickListener = object: OnVisibleClickListener{
override fun onVisibleClickListener(item: ItemUbicadorVO) {
showAddItem(item.item,item.packing,item.stickers,item.visible)
}
},onMoreClickListener = object: OnMoreClickListener{
override fun onMoreClickListener(item: ItemUbicadorVO) {
customDialogTwoButtons.setTitle(item.item).setDescription("Selecciona una acción").setOkButton("Transferir"){
customDialogInput.setTitle("Nueva matrícula").setDescription("Introduce el destino para item: "+item.item).setValue("").setOkButton("Transferir"){
viewModel.itemShelvingTransfer(user,password,item.id,customDialogInput.getValue())
listItems.remove(item)
adapter!!.notifyDataSetChanged()
customDialogInput.hide()
}.setKoButton("Cancelar"){
customDialogInput.hide()
}.show()
customDialogInput.getEditText().requestFocus()
(activity as MainActivity).hideKeyboard(customDialogInput.getEditText())
customDialogInput.getEditText().setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || actionId == 0) {
viewModel.itemShelvingTransfer(user,password,item.id,customDialogInput.getValue())
listItems.remove(item)
adapter!!.notifyDataSetChanged()
customDialogInput.hide()
return@setOnEditorActionListener true
}
false
}
customDialogTwoButtons.hide()
}.setOkButtonTwo("Eliminar"){
listItems.remove(item)
adapter!!.notifyDataSetChanged()
viewModel.itemShelvingDelete(user,password,item.id)
customDialogTwoButtons.hide()
}.setKoButton("Cancelar"){
customDialogTwoButtons.hide()
}.show()
}
})
location_recyclerview.adapter = adapter
location_recyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
location_recyclerview.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, true)
}
})
response.observe(viewLifecycleOwner, Observer {
if (it.isError){
mperror!!.start()
customDialog.setTitle("Error").setDescription(it.errorMessage).setOkButton("Cerrar"){
customDialog.hide()
}.show()
@ -157,8 +295,8 @@ class UbicadorFragment(
}
}
private fun showAddItem(){
customDialogUbicador.setTitle("Nuevo item").setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("").setOkButton("Guardar"){
private fun showAddItem(itemFk:String,packing: String,etiquetas: String,visible: String){
customDialogUbicador.setTitle("Nuevo item").setItemValue(itemFk).setPackingValue(packing).setEtiquetaValue(etiquetas).setVisibleValue(visible).setOkButton("Guardar"){
saveNewItem(customDialogUbicador.getItemValue(),customDialogUbicador.getEtiquetaValue(),customDialogUbicador.getPackingValue(),customDialogUbicador.getVisibleValue())
}.setKoButton("Cerrar"){
customDialogUbicador.hide()

View File

@ -76,6 +76,79 @@ class UbicadorViewModel : BaseViewModel() {
})
}
fun shelvingPark(usuario:String,password:String,shelving:String,parking:String){
getUbicadorUserCase.shelvingPark(usuario,password,shelving,parking).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+shelving+ " Respuesta:"+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 shelvingChange(usuario:String,password:String,origen:String,destino:String){
getUbicadorUserCase.shelvingChange(usuario,password,origen,destino).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+origen+ " Respuesta:"+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 shelvingChange")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun clearShelvingList(usuario:String,password:String,shelvingFk:String){
getUbicadorUserCase.clearShelvingList(usuario,password,shelvingFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+shelvingFk+ " Respuesta:"+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 clearShelvingList")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun itemShelvingTransfer(usuario:String,password:String,itemFk:String,shelvingFk:String){
getUbicadorUserCase.itemShelvingTransfer(usuario,password,itemFk,shelvingFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+itemFk+ " Respuesta:"+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 itemShelvingTransfer")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun itemShelvingDelete(usuario:String,password:String,itemFk:String){
getUbicadorUserCase.itemShelvingDelete(usuario,password,itemFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_response.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+itemFk+ " Respuesta:"+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 itemShelvingDelete")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
}

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,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
</vector>

View File

@ -49,16 +49,19 @@
android:textColorHint="@android:color/darker_gray" />
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="@+id/delete_img"
android:layout_width="@dimen/options_image_width"
android:layout_height="match_parent"
android:src="@drawable/ic_delete_forever_black_24dp"
android:padding="@dimen/options_image_padding"/>
<ImageView
android:id="@+id/edit_img"
android:layout_width="@dimen/options_image_width"
android:layout_height="match_parent"
android:src="@drawable/ic_mode_edit_black_24dp"
android:padding="@dimen/options_image_padding"/>
<ImageView
android:id="@+id/parking_img"
android:layout_width="@dimen/options_image_width"
android:layout_height="match_parent"
android:src="@drawable/ic_local_parking_black_24dp"

View File

@ -69,6 +69,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/layer_visible"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
@ -96,6 +97,18 @@
android:gravity="center"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="@dimen/item_image_width_min"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/more_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="center"
android:src="@drawable/ic_more_vert_black_24dp" />
</LinearLayout>
</LinearLayout>

Binary file not shown.

BIN
app/src/main/res/raw/ok.mp3 Normal file

Binary file not shown.

View File

@ -73,6 +73,7 @@
<dimen name="options_image_width">40dp</dimen>
<dimen name="options_image_padding">10dp</dimen>
<dimen name="item_image_width">40dp</dimen>
<dimen name="item_image_width_min">33dp</dimen>