This commit is contained in:
Enrique Blasco 2020-09-14 06:58:16 +02:00
parent 9ec2bfcc45
commit 145fad6f5f
14 changed files with 174 additions and 25 deletions

View File

@ -12,8 +12,8 @@ android {
applicationId "es.verdnatura"
minSdkVersion 21
targetSdkVersion 29
versionCode 29
versionName "5.1.9"
versionCode 32
versionName "5.2.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -8,8 +8,8 @@ import java.util.concurrent.TimeUnit
class ApiUtils {
companion object {
//const val BASE_URL:String = "http://192.168.0.12:8009/"
const val BASE_URL:String = "https://app.verdnatura.es/"
const val BASE_URL:String = "http://192.168.1.33:8009/"
//const val BASE_URL:String = "https://app.verdnatura.es/"
fun getApiService():VerdnaturaService{
val retrofit = Retrofit.Builder()
.baseUrl(BASE_URL)

View File

@ -2,6 +2,7 @@ package es.verdnatura.domain
import es.verdnatura.presentation.view.feature.collection.ItemVO
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeVO
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO
import retrofit2.Call
@ -118,5 +119,18 @@ class GetSacadorControladorUserCase : RestClient() {
return restClient!!.collectionIncreaseQuantity("json","1",usuario,password,"application/json",params)
}
fun saleMistakeAdd(usuario:String,password:String,vSaleFk: String, vUserFk: String, vTypeFk: String) : Call<String> {
val params:ArrayList<String> = ArrayList()
params.add(vSaleFk)
params.add(vUserFk)
params.add(vTypeFk)
return restClient!!.saleMistakeAdd("json","1",usuario,password,"application/json",params)
}
fun mistakeType(usuario:String,password:String) : Call<List<MistakeTypeVO>> {
val params:ArrayList<String> = ArrayList();
return restClient!!.mistakeType("json","1",usuario,password,"application/json")
}
}

View File

@ -23,7 +23,7 @@ class GetUbicadorUserCase : RestClient() {
return restClient!!.itemShelvingMake("json","1",usuario,password,"application/json",params)
}
fun itemShelvingMakeEdit(usuario:String,password:String,shelving:String,item:String,deep:String,quantity:String,packing:String,warehouse:String,level:String) : Call<String> {
fun itemShelvingMakeEdit(usuario:String,password:String,shelving:String,item:String,deep:String,quantity:String,packing:String,warehouse:String,level:String,itemShelvingFk:String) : Call<String> {
val params:ArrayList<String> = ArrayList();
params.add(shelving)
params.add(item)
@ -32,6 +32,7 @@ class GetUbicadorUserCase : RestClient() {
params.add(packing)
params.add(warehouse)
params.add(level)
params.add(itemShelvingFk)
return restClient!!.itemShelvingMakeEdit("json","1",usuario,password,"application/json",params)
}

View File

@ -12,6 +12,7 @@ import es.verdnatura.presentation.view.feature.inventario.model.ItemInventaryVO
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.MistakeTypeVO
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO
import es.verdnatura.presentation.view.feature.sacador.model.PlacementVO
import es.verdnatura.presentation.view.feature.shelvingparking.model.ItemShelvingParkingVO
@ -204,6 +205,24 @@ interface VerdnaturaService {
@Body params: List<String>):
Call<String>
@POST("almacennew/saleMistakeAdd")
fun saleMistakeAdd(@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params: List<String>):
Call<String>
@POST("almacennew/mistakeType")
fun mistakeType(@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String):
Call<List<MistakeTypeVO>>
//PASILLEROS ========================================================================>
//CONSULTAR ARTICULO ========================================================================>

View File

@ -90,4 +90,8 @@ interface OnQuantityClickListener {
interface OnSaleClickListener {
fun onSaleClick(sale: SaleVO)
}
interface OnMistakeClickListener {
fun onMistakeClickListener(sale:SaleVO)
}

View File

@ -83,4 +83,9 @@ class CustomDialogList (context: Context) : Dialog(context, R.style.DialogTheme)
return this
}
fun hideDialog():CustomDialogList{
custom_dialog_value.visibility = View.GONE
return this
}
}

View File

@ -9,6 +9,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import es.verdnatura.R
import es.verdnatura.databinding.ItemArticleRowBinding
import es.verdnatura.presentation.common.OnMistakeClickListener
import es.verdnatura.presentation.common.OnPasillerosItemClickListener
import es.verdnatura.presentation.common.OnQuantityClickListener
import es.verdnatura.presentation.common.OnSaleClickListener
@ -19,7 +20,8 @@ class SaleAdapter (
private val items: List<SaleVO>,
private val onPasillerosItemClickListener: OnPasillerosItemClickListener,
private val onQuantityClick: OnQuantityClickListener,
private val onSaleClickListener: OnSaleClickListener
private val onSaleClickListener: OnSaleClickListener,
private val onMistakeClickListener: OnMistakeClickListener
): RecyclerView.Adapter<SaleAdapter.AjustesItemHolder> () {
var context:Context? = null
var position:Int = 0
@ -74,6 +76,11 @@ class SaleAdapter (
onQuantityClick.onQuantityClick(sale)
}
contentLayout.setOnLongClickListener {
onMistakeClickListener.onMistakeClickListener(sale)
false
}
//ERROR
if (sale.originalQuantity != sale.quantity){
layoutError.visibility = View.VISIBLE

View File

@ -36,10 +36,7 @@ import es.verdnatura.presentation.view.feature.collection.ItemVO
import es.verdnatura.presentation.view.feature.collection.adapter.SaleAdapter
import es.verdnatura.presentation.view.feature.inventario.adapter.ToolBarAdapter
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyListVO
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO
import es.verdnatura.presentation.view.feature.sacador.model.SaleVO
import es.verdnatura.presentation.view.feature.sacador.model.*
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.fragment_collection.*
import kotlinx.android.synthetic.main.toolbar.*
@ -74,6 +71,7 @@ class CollectionFragment(
private var itemShelvingFkStored : String = ""
private var storedBackPosition : Int = 0
private var tickets:ArrayList<String> = ArrayList()
private var mistakeSale:SaleVO? = null
private var myKM: KeyguardManager? = null
@ -282,6 +280,12 @@ class CollectionFragment(
viewModel.collectionTicketGet(user,password,collection.collectionFk,sectorFk)*/
})
mistakeList.observe(viewLifecycleOwner, Observer {
splash_progress.visibility = View.GONE
if (!goBack) showMistakeList(it.list)
goBack = false
})
}
}
@ -329,6 +333,12 @@ class CollectionFragment(
}
}
},object: OnMistakeClickListener{
override fun onMistakeClickListener(sale: SaleVO) {
splash_progress.visibility = View.VISIBLE
mistakeSale = sale
viewModel.mistakeType(usuario = user, password = password)
}
})
lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
fragment_sacador_collections.adapter = saleAdapter
@ -1057,7 +1067,7 @@ class CollectionFragment(
//enviar mensaje a salix
val ticket = "[" + sales[position].ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + sales[position].ticketFk + "/summary)"
val message = "Se ha enviado a Faltas el articulo "+sales[position].itemFk+" del ticket "+ticket
val message = "Se ha enviado a Faltas la cantidad de "+ totalQuantity +" del articulo "+sales[position].itemFk+" ticket "+ticket
viewModel.sendChekingPresence(token = token,workerId = sales[position].salePersonFk,message = message)
}
@ -1086,7 +1096,7 @@ class CollectionFragment(
//enviar mensaje a salix
val ticket = "[" + sales[position].ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + sales[position].ticketFk + "/summary)"
val message = "Se ha enviado a Basura el articulo "+sales[position].itemFk+" del ticket "+ticket
val message = "Se ha enviado a Basura "+ totalQuantity +" del articulo "+sales[position].itemFk+" ticket "+ticket
viewModel.sendChekingPresence(token = token,workerId = sales[position].salePersonFk,message = message)
}
@ -1226,7 +1236,38 @@ class CollectionFragment(
}.show()
}
private fun showMistakeList(list:List<MistakeTypeVO>){
splash_progress.visibility = View.GONE
listPlacementSupply = ArrayList()
list.forEach {
listPlacementSupply.add(BarcodeVO(code = it.description))
}
customDialogList.setTitle("Causa de error").setKoButton("Cerrar") {
scanRequest()
hideKeyboards()
customDialogList.dismiss()
}.hideDialog().show()
placementSupplyAdapter = BarcodeAdapter(listPlacementSupply,object: OnBarcodeRowClickListener {
override fun onBarcodeRowClickListener(item: BarcodeVO) {
list.forEach {
if (it.description == item.code){
viewModel.saleMistakeAdd(usuario = user,password = password,vSaleFk = mistakeSale?.saleFk!!,vUserFk = mistakeSale?.workerFk!!,vTypeFk = it.id)
"Causa del error registrado".toast(requireContext())
customDialogList.dismiss()
}
}
}
},showDelete = false)
customDialogList.getRecyclerView().adapter = placementSupplyAdapter
customDialogList.getRecyclerView().layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
}
}

View File

@ -11,9 +11,7 @@ import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.collection.ItemVO
import es.verdnatura.presentation.view.feature.collection.mapper.map
import es.verdnatura.presentation.view.feature.login.model.SalixMessageVO
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyListVO
import es.verdnatura.presentation.view.feature.sacador.model.PlacementSupplyVO
import es.verdnatura.presentation.view.feature.sacador.model.*
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
@ -50,6 +48,10 @@ class CollectionViewModel : BaseViewModel() {
val responseIncQuantity: LiveData<ResponseItemVO>
get() = _responseIncQuantity
private val _mistakeList by lazy { MutableLiveData<MistakeTypeListVO>() }
val mistakeList: LiveData<MistakeTypeListVO>
get() = _mistakeList
private val _item by lazy { MutableLiveData<ItemVO>() }
@ -306,4 +308,47 @@ class CollectionViewModel : BaseViewModel() {
}catch (e:Exception){}
}
fun saleMistakeAdd(usuario:String,password:String,vSaleFk: String, vUserFk: String, vTypeFk: String){
getSacadorControladorUserCase.saleMistakeAdd(usuario,password,vSaleFk,vUserFk,vTypeFk).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 saleMistakeAdd")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun mistakeType(usuario:String,password:String){
getSacadorControladorUserCase.mistakeType(usuario,password).enqueue(object : Callback<List<MistakeTypeVO>>{
override fun onFailure(call: Call<List<MistakeTypeVO>>, t: Throwable) {
val listError:ArrayList<MistakeTypeVO> = ArrayList()
listError.add(MistakeTypeVO("0",""))
_mistakeList.value = MistakeTypeListVO(listError)
}
override fun onResponse(
call: Call<List<MistakeTypeVO>>,
response: Response<List<MistakeTypeVO>>
) {
if (response.body() != null){
_mistakeList.value = response.body()?.let { MistakeTypeListVO(it) }
}else{
val listError:ArrayList<MistakeTypeVO> = ArrayList()
listError.add(MistakeTypeVO("0",""))
_mistakeList.value = MistakeTypeListVO(listError)
}
}
})
}
}

View File

@ -4,8 +4,11 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetSacadorControladorUserCase
import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.common.ResponseItemVO
import es.verdnatura.presentation.view.feature.collection.mapper.map
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeListVO
import es.verdnatura.presentation.view.feature.sacador.model.MistakeTypeVO
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
@ -18,6 +21,7 @@ class ControladorViewModel : BaseViewModel() {
val collectionTicketList: LiveData<CollectionVO>
get() = _collectionTicketList
fun collectionTicketGet(usuario:String,password:String,collectionFk:String,sectorFk:String){
getSacadorControladorUserCase.collectionTicketGet(usuario,password,collectionFk,sectorFk,"0").enqueue(object :
Callback<CollectionVO> {
@ -36,4 +40,6 @@ class ControladorViewModel : BaseViewModel() {
}
})
}
}

View File

@ -91,5 +91,12 @@ class PlacementSupplyListVO (
var list: List<PlacementSupplyVO> = listOf()
)
class MistakeTypeVO (
var id : String = "",
var description : String = ""
)
class MistakeTypeListVO (
var list: List<MistakeTypeVO> = listOf()
)

View File

@ -104,7 +104,7 @@ class UbicadorFragment(
toolbar_icons.adapter = ToolBarAdapter(listIcons,object: OnOptionsSelectedListener {
override fun onOptionsItemSelected(item: Drawable) {
if (item == iconAdd){
showAddItem("","","","",false,null)
showAddItem("","","","",false,ItemUbicadorVO())
}else if(item == iconReload){
splash_progress.visibility = View.VISIBLE
viewModel.itemShelvingList(user,password,shelvingFk)
@ -288,7 +288,7 @@ class UbicadorFragment(
}
}
private fun showAddItem(itemFk:String,packing: String,etiquetas: String,visible: String, delete:Boolean,itemUbicador:ItemUbicadorVO?){
private fun showAddItem(itemFk:String,packing: String,etiquetas: String,visible: String, delete:Boolean,itemUbicador:ItemUbicadorVO){
var title = "Nuevo Item"
if (delete) title = "Editar item "+itemFk
customDialogUbicador.setTitle(title).setItemValue(itemFk).setPackingValue(packing).setEtiquetaValue(etiquetas).setVisibleValue(visible).setOkButton("Guardar"){
@ -296,7 +296,7 @@ class UbicadorFragment(
if (packing != customDialogUbicador.getPackingValue() || etiquetas != customDialogUbicador.getEtiquetaValue()){
packingUpdate = true
}
saveNewItem(customDialogUbicador.getItemValue(),customDialogUbicador.getEtiquetaValue(),customDialogUbicador.getPackingValue(),customDialogUbicador.getVisibleValue(),if (delete)packingUpdate else null)
saveNewItem(customDialogUbicador.getItemValue(),customDialogUbicador.getEtiquetaValue(),customDialogUbicador.getPackingValue(),customDialogUbicador.getVisibleValue(),if (delete)packingUpdate else null,itemUbicador.id)
}.setKoButton("Cerrar"){
customDialogUbicador.dismiss()
}.show()
@ -310,7 +310,7 @@ class UbicadorFragment(
if (packing != customDialogUbicador.getPackingValue() || etiquetas != customDialogUbicador.getEtiquetaValue()){
packingUpdate = true
}
saveNewItem(customDialogUbicador.getItemValue(),customDialogUbicador.getEtiquetaValue(),customDialogUbicador.getPackingValue(),customDialogUbicador.getVisibleValue(),if (delete)packingUpdate else null)
saveNewItem(customDialogUbicador.getItemValue(),customDialogUbicador.getEtiquetaValue(),customDialogUbicador.getPackingValue(),customDialogUbicador.getVisibleValue(),if (delete)packingUpdate else null,itemUbicador.id)
return@setOnEditorActionListener true
}
false
@ -322,7 +322,7 @@ class UbicadorFragment(
if (packing != customDialogUbicador.getPackingValue() || etiquetas != customDialogUbicador.getEtiquetaValue()){
packingUpdate = true
}
saveNewItem(customDialogUbicador.getItemValue(),customDialogUbicador.getEtiquetaValue(),customDialogUbicador.getPackingValue(),customDialogUbicador.getVisibleValue(),if (delete)packingUpdate else null)
saveNewItem(customDialogUbicador.getItemValue(),customDialogUbicador.getEtiquetaValue(),customDialogUbicador.getPackingValue(),customDialogUbicador.getVisibleValue(),if (delete)packingUpdate else null,itemUbicador.id)
return@setOnEditorActionListener true
}
false
@ -330,7 +330,7 @@ class UbicadorFragment(
}
private fun saveNewItem(itemFk:String,etiquetas:String,packing:String,visible:String,updatePacking:Boolean? = null){
private fun saveNewItem(itemFk:String,etiquetas:String,packing:String,visible:String,updatePacking:Boolean? = null,itemShelvingFk:String){
if (!packing.isNullOrEmpty()){
if (updatePacking == null){
if (!itemFk.isNullOrEmpty() && !visible.isNullOrEmpty()){
@ -355,7 +355,7 @@ class UbicadorFragment(
}
}else{
if (!itemFk.isNullOrEmpty() && !visible.isNullOrEmpty() && !updatePacking){
viewModel.itemShelvingMakeEdit(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1")
viewModel.itemShelvingMakeEdit(user,password,shelvingFk,itemFk,deep.toString(),visible,packing,warehouseFk,"1",itemShelvingFk)
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible,packing = packing))
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus()
@ -364,7 +364,7 @@ class UbicadorFragment(
}else if(!itemFk.isNullOrEmpty() && !etiquetas.isNullOrEmpty() && updatePacking){
val visible_calc = (etiquetas.toInt() * packing.toInt()).toString()
viewModel.itemShelvingMakeEdit(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1")
viewModel.itemShelvingMakeEdit(user,password,shelvingFk,itemFk,deep.toString(),visible_calc,packing,warehouseFk,"1",itemShelvingFk)
changeOfflineValue(ItemUbicadorVO(item = itemFk,visible = visible_calc,packing = packing,stickers = etiquetas))
customDialogUbicador.setItemValue("").setPackingValue("").setEtiquetaValue("").setVisibleValue("")
customDialogUbicador.getEditItem().requestFocus()

View File

@ -94,8 +94,8 @@ class UbicadorViewModel : BaseViewModel() {
})
}
fun itemShelvingMakeEdit(usuario:String,password:String,shelving:String,item:String,deep:String,quantity:String,packing:String,warehouse:String,level:String){
getUbicadorUserCase.itemShelvingMakeEdit(usuario,password,shelving,item,deep,quantity,packing,warehouse,level).enqueue(object : Callback<String>{
fun itemShelvingMakeEdit(usuario:String,password:String,shelving:String,item:String,deep:String,quantity:String,packing:String,warehouse:String,level:String,itemShelvingFk:String){
getUbicadorUserCase.itemShelvingMakeEdit(usuario,password,shelving,item,deep,quantity,packing,warehouse,level,itemShelvingFk).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_responseMake.value = ResponseItemVO(isError = true,errorMessage ="Error al guardar item: "+item+ " Respuesta:"+t.message!!)
}