This commit is contained in:
Enrique Blasco Blanquer 2020-09-30 10:55:32 +02:00
parent 321dd9b963
commit f180658242
30 changed files with 2115 additions and 63 deletions

View File

@ -14,8 +14,8 @@ android {
applicationId "es.verdnatura"
minSdkVersion 21
targetSdkVersion 29
versionCode 34
versionName "5.2.4"
versionCode 39
versionName "5.2.9"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.PREVENT_POWER_KEY" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<application
android:name=".MobileApplication"

View File

@ -16,6 +16,7 @@ import es.verdnatura.presentation.view.feature.paletizador.fragment.ExpeditionTr
import es.verdnatura.presentation.view.feature.parking.fragment.ParkingViewModel
import es.verdnatura.presentation.view.feature.pasillero.fragment.PasilleroViewModel
import es.verdnatura.presentation.view.feature.presacador.fragment.PreSacadorViewModel
import es.verdnatura.presentation.view.feature.reposicion.fragment.ReposicionViewModel
import es.verdnatura.presentation.view.feature.sacador.fragment.SacadorViewModel
import es.verdnatura.presentation.view.feature.shelvingparking.fragment.ShelvingParkingViewModel
import es.verdnatura.presentation.view.feature.ubicador.fragment.AutomaticAddItemViewModel
@ -115,4 +116,8 @@ val viewModelModule = module{
viewModel {
PreSacadorViewModel()
}
viewModel {
ReposicionViewModel()
}
}

View File

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

View File

@ -12,4 +12,19 @@ class GetPreSacadorUseCase() : RestClient() {
return restClient!!.ticketToPrePrepare("json","1",usuario,password,"application/json",params)
}
fun itemPlacementSupplyGetOrder(usuario:String,password:String,sectorFk:String) : Call<List<PreSacadorItemVO>> {
val params:ArrayList<String> = ArrayList();
params.add(sectorFk)
return restClient!!.itemPlacementSupplyGetOrder("json","1",usuario,password,"application/json",params)
}
fun itemPlacementSupplyCloseOrder(usuario:String,password:String,id:String,quantity:String) : Call<String> {
val params:ArrayList<String> = ArrayList();
params.add(id)
params.add(quantity)
return restClient!!.itemPlacementSupplyCloseOrder("json","1",usuario,password,"application/json",params)
}
}

View File

@ -52,6 +52,14 @@ class GetSacadorControladorUserCase : RestClient() {
return restClient!!.itemShelvingSaleSupplyAdd("json","1",usuario,password,"application/json",params)
}
fun itemShelvingPlacementSupplyAdd(usuario:String,password:String,itemShelvingFk:String,itemPlacementSupplyFk:String,quantity:String) : Call<String> {
val params:ArrayList<String> = ArrayList();
params.add(itemShelvingFk)
params.add(itemPlacementSupplyFk)
params.add(quantity)
return restClient!!.itemShelvingPlacementSupplyAdd("json","1",usuario,password,"application/json",params)
}
fun collectionStickerPrint(usuario:String,password:String,collectionFk: String,sectorFk: String) : Call<String> {
val params:ArrayList<String> = ArrayList()
params.add(collectionFk)

View File

@ -68,6 +68,25 @@ interface VerdnaturaService {
Call<List<PreSacadorItemVO>>
@POST("almacennew/itemPlacementSupplyGetOrder")
fun itemPlacementSupplyGetOrder(@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>>
@POST("almacennew/itemPlacementSupplyCloseOrder")
fun itemPlacementSupplyCloseOrder(@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>
//SACADORES / CONTROLADORES ========================================================================>
@ -124,6 +143,15 @@ interface VerdnaturaService {
@Body params: List<String>):
Call<String>
@POST("almacennew/itemShelvingPlacementSupplyAdd")
fun itemShelvingPlacementSupplyAdd(@Header("aplicacion") aplicacion: String,
@Header("version") version: String,
@Header("user") user: String,
@Header("pass") pass: String,
@Header("Content-Type") content_type: String,
@Body params: List<String>):
Call<String>
@POST("almacennew/collectionStickerPrint")
fun collectionStickerPrint(@Header("aplicacion") aplicacion: String,
@Header("version") version: String,

View File

@ -1,19 +1,38 @@
package es.verdnatura.presentation.base
import android.Manifest
import android.Manifest.permission
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.media.AudioManager
import android.os.Build
import android.os.Bundle
import android.speech.RecognitionListener
import android.speech.RecognizerIntent
import android.speech.SpeechRecognizer
import android.speech.tts.TextToSpeech
import android.speech.tts.UtteranceProgressListener
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.core.content.PermissionChecker.checkCallingOrSelfPermission
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import es.verdnatura.domain.toast
import es.verdnatura.presentation.common.mediaCurrentVolume
import es.verdnatura.presentation.common.mediaMaxVolume
import es.verdnatura.presentation.common.setMediaVolume
import org.koin.androidx.viewmodel.ext.android.viewModel
import java.util.*
import kotlin.reflect.KClass
abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelClass: KClass<V>) :
Fragment() {
Fragment(), TextToSpeech.OnInitListener , RecognitionListener{
protected val PREFS_USER = "es.verdnatura.user.prefs"
@ -25,10 +44,35 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
protected val SECTORFK = "sectorFk"
protected val WAREHOUSEFK = "warehouseFk"
protected val RECORDAR = "recordar"
protected val VOZ = "voz"
protected val viewModel: V by viewModel(viewModelClass)
protected lateinit var binding: T
private var textToSpeech: TextToSpeech? = null
private var mAudioManager:AudioManager? = null
protected var mSpeechRecognizer: SpeechRecognizer? = null
private var mSpeechRecognizerIntent: Intent? = null
protected val NEW_COLLECTION = 0
protected val LISTO = 1
protected val CANCEL = 2
protected val VOLVER = 3
protected val REPITE = 4
protected val OTRO = 5
protected val FALTA = 6
protected val ERROR = -1
val allowedStrings =
Arrays.asList(
"cero", "uno", "dos", "tres", "cuatro", "cinco", "seis", "siete",
"ocho", "nueve", "diez", "once", "doce", "trece", "catorce",
"quince", "dieziseis", "diezisiete", "dieziocho", "diezinueve", "veinte",
"treinta", "cuarenta", "cincuenta", "sesenta", "setenta", "ochenta", "noventa",
"cien", "mil"
)
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
@ -37,11 +81,11 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
initDataBinding()
getBundleArguments()
observeViewModel()
runSound()
requestRecordAudioPermission()
init()
}
@ -52,6 +96,32 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
open fun getBundleArguments() {}
open fun addBindingVariables() {}
open fun setSpeak() {
//VOZ
textToSpeech = TextToSpeech(requireContext(),this)
mAudioManager = requireActivity().getSystemService(Context.AUDIO_SERVICE) as AudioManager
}
open fun initialize(){
//ESCUCHA
try {
mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(requireContext())
mSpeechRecognizerIntent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
mSpeechRecognizerIntent!!.putExtra(
RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM
)
mSpeechRecognizerIntent!!.putExtra(
RecognizerIntent.EXTRA_LANGUAGE,
Locale.getDefault()
)
mSpeechRecognizerIntent!!.putExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, true)
mSpeechRecognizer?.setRecognitionListener(this)
startListening()
}catch (e:Exception){
cancelSpeech()
}
}
private fun initDataBinding() {
binding = DataBindingUtil.bind<T>(view!!)!!
@ -62,4 +132,268 @@ abstract class BaseFragment<T : ViewDataBinding, V : BaseViewModel>(viewModelCla
}
override fun onInit(status: Int) {
if (status == TextToSpeech.SUCCESS) {
val spanish = Locale("es", "ES")
textToSpeech!!.language = spanish
textToSpeech!!.setOnUtteranceProgressListener(object: UtteranceProgressListener() {
override fun onDone(utteranceId: String?) {
Log.i("SPEEAK","on done")
requireActivity().runOnUiThread(Runnable {
if (mSpeechRecognizer != null){
mSpeechRecognizer!!.destroy()
mSpeechRecognizer = null
}
initialize()
})
}
override fun onError(utteranceId: String?) {
"Error to speak".toast(requireContext())
}
override fun onStart(utteranceId: String?) {
Log.i("SPEEAK","on start")
runSound()
}
})
}else{
"La voz no se ha podido iniciar".toast(requireContext())
}
}
private fun runSound(){
// Get the maximum media/music volume
val maxVolume = mAudioManager?.mediaMaxVolume
mAudioManager?.setMediaVolume(maxVolume!! / 2)
}
private fun muteSound() {
if (mAudioManager?.mediaCurrentVolume != 0){
mAudioManager?.setMediaVolume(0)
}
}
fun speak(frase:String) {
textToSpeech!!.speak(frase, TextToSpeech.QUEUE_FLUSH, null, "frase")
}
open fun startListening() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
muteSound()
}
mSpeechRecognizer!!.startListening(mSpeechRecognizerIntent)
}
override fun onReadyForSpeech(params: Bundle?) {
Log.i("Speech", "onReadyForSpeech")
}
override fun onBeginningOfSpeech() {
Log.i("Speech", "onBeginningOfSpeech")
}
override fun onRmsChanged(rmsdB: Float) {}
override fun onBufferReceived(buffer: ByteArray?) {
Log.i("Speech", "onBufferReceived")
}
override fun onEndOfSpeech() {
Log.i("Speech", "onEndOfSpeech")
}
override fun onError(error: Int) {
Log.i("Speech", "onError "+error)
mSpeechRecognizer!!.destroy()
mSpeechRecognizer = null
initialize()
}
override fun onResults(results: Bundle) {}
override fun onPartialResults(partialResults: Bundle?) {
Log.i("Speech", "onPartialResults")
}
override fun onEvent(eventType: Int, params: Bundle?) {
Log.i("Speech", "onEvent")
}
open fun checkText(text: String): Int {
//check for nuevo
val nuevo = getMatch(text, "nuevo")
//check for listo
val listo = getMatch(text, "listo")
//check for cancelar
val cancelar = getMatch(text, "cancelar")
//check for volver
val volver = getMatch(text, "volver")
//check for repite
val repite = getMatch(text, "repite")
//check for siguiente
val otro = getMatch(text, "otro")
//check for FALTA
val falta = getMatch(text, "falta")
val words = IntArray(7)
words[0] = nuevo
words[1] = listo
words[2] = cancelar
words[3] = volver
words[4] = repite
words[5] = otro
words[6] = falta
return getMax(words)
}
private fun getMax(a: IntArray): Int {
var max = a[0]
var pos = 0
for (i in a.indices) {
if (a[i] > max) {
max = a[i]
pos = i
}
}
return if (max < 80) {
-1
} else pos
}
private fun getMatch(a: String, b: String): Int {
var count = 0
val cha = a.toCharArray()
val chb = b.toCharArray()
for (i in cha) {
for (x in chb) {
if (x == i) {
count += 1
break
}
}
}
val numChar = a.length
return count * 100 / numChar
}
private fun requestRecordAudioPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val requiredPermission: String = Manifest.permission.RECORD_AUDIO
val res = context!!.checkCallingOrSelfPermission(requiredPermission)
// If the user previously denied this permission then show a message explaining why
// this permission is needed
if (res == PackageManager.PERMISSION_DENIED) {
requestPermissions(arrayOf(requiredPermission), 101)
}
}
}
fun cancelSpeech(){
if (mSpeechRecognizer != null){
mSpeechRecognizer!!.destroy()
mSpeechRecognizer = null
}
}
/*open fun wordToNumber(input: String?): Int {
var input = input
var isValidInput = true
var result = 0
var finalResult = 0
if (input != null && input.length > 0) {
input = input.replace("-".toRegex(), " ")
input = input.toLowerCase().replace(" and".toRegex(), " ")
val splittedParts =
input.trim { it <= ' ' }.split("\\s+".toRegex()).toTypedArray()
for (str in splittedParts) {
if (!es.verdnatura.warehouse.UTILS.Utils.allowedStrings.contains(str)) {
isValidInput = false
return -1
}
}
if (isValidInput) {
for (str in splittedParts) {
if (str.equals("cero", ignoreCase = true)) {
result += 0
} else if (str.equals("uno", ignoreCase = true)) {
result += 1
} else if (str.equals("dos", ignoreCase = true)) {
result += 2
} else if (str.equals("tres", ignoreCase = true)) {
result += 3
} else if (str.equals("cuatro", ignoreCase = true)) {
result += 4
} else if (str.equals("cinco", ignoreCase = true)) {
result += 5
} else if (str.equals("seis", ignoreCase = true)) {
result += 6
} else if (str.equals("siete", ignoreCase = true)) {
result += 7
} else if (str.equals("ocho", ignoreCase = true)) {
result += 8
} else if (str.equals("nueve", ignoreCase = true)) {
result += 9
} else if (str.equals("diez", ignoreCase = true)) {
result += 10
} else if (str.equals("once", ignoreCase = true)) {
result += 11
} else if (str.equals("doce", ignoreCase = true)) {
result += 12
} else if (str.equals("trece", ignoreCase = true)) {
result += 13
} else if (str.equals("catorce", ignoreCase = true)) {
result += 14
} else if (str.equals("quince", ignoreCase = true)) {
result += 15
} else if (str.equals("dieziseis", ignoreCase = true)) {
result += 16
} else if (str.equals("diezisiete", ignoreCase = true)) {
result += 17
} else if (str.equals("dieziocho", ignoreCase = true)) {
result += 18
} else if (str.equals("diezinueve", ignoreCase = true)) {
result += 19
} else if (str.equals("veinte", ignoreCase = true)) {
result += 20
} else if (str.equals("treinta", ignoreCase = true)) {
result += 30
} else if (str.equals("cuarenta", ignoreCase = true)) {
result += 40
} else if (str.equals("cincuenta", ignoreCase = true)) {
result += 50
} else if (str.equals("sesenta", ignoreCase = true)) {
result += 60
} else if (str.equals("setenta", ignoreCase = true)) {
result += 70
} else if (str.equals("ochenta", ignoreCase = true)) {
result += 80
} else if (str.equals("noventa", ignoreCase = true)) {
result += 90
} else if (str.equals("cien", ignoreCase = true)) {
result *= 100
} else if (str.equals("mil", ignoreCase = true)) {
result *= 1000
finalResult += result
result = 0
}
}
finalResult += result
return finalResult
}
}
return finalResult
}*/
}

View File

@ -5,6 +5,7 @@ import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.media.AudioManager
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
@ -140,4 +141,24 @@ fun Activity.hideKeyboard() {
fun Context.hideKeyboard(view: View) {
val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
val hideSoftInputFromWindow = inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
}
}
// Extension function to change media volume programmatically
fun AudioManager.setMediaVolume(volumeIndex:Int) {
// Set media volume level
this.setStreamVolume(
AudioManager.STREAM_MUSIC, // Stream type
volumeIndex, // Volume index
AudioManager.FLAG_SHOW_UI// Flags
)
}
// Extension property to get media maximum volume index
val AudioManager.mediaMaxVolume:Int
get() = this.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
// Extension property to get media/music current volume index
val AudioManager.mediaCurrentVolume:Int
get() = this.getStreamVolume(AudioManager.STREAM_MUSIC)

View File

@ -25,6 +25,7 @@ class AjustesFragment : BaseFragment<FragmentAjustesBinding,AjustesViewModel>(Aj
private var password:String? = ""
private lateinit var customDialog: CustomDialog
private var sectorListVO:List<SectorItemVO> = listOf()
private var vozList:List<String> = listOf()
private var prefs: SharedPreferences? = null
private var ajustesAdapter: AjustesAdapter? = null
@ -36,7 +37,7 @@ class AjustesFragment : BaseFragment<FragmentAjustesBinding,AjustesViewModel>(Aj
override fun onCreate(savedInstanceState: Bundle?) {
prefs = activity!!.getSharedPreferences(PREFS_USER,0)
customDialog = CustomDialog(requireContext())
viewModel.inititializeDefaultAjusts(prefs!!.getString(SECTORDESCRIP,getString(R.string.Sinsector)).toString(),prefs!!.getInt(SECTORFK,0),prefs!!.getInt(WAREHOUSEFK,0))
viewModel.inititializeDefaultAjusts(prefs!!.getString(SECTORDESCRIP,getString(R.string.Sinsector)).toString(),prefs!!.getInt(SECTORFK,0),prefs!!.getInt(WAREHOUSEFK,0),prefs!!.getString(VOZ,"NO").toString())
super.onCreate(savedInstanceState)
}
@ -64,7 +65,12 @@ class AjustesFragment : BaseFragment<FragmentAjustesBinding,AjustesViewModel>(Aj
}else if (item.id == 2){
getString(R.string.Nodisponibleenestaversión).toast(requireContext())
}else if (item.id == 3){
getString(R.string.Nodisponibleenestaversión).toast(requireContext())
val listVoz : ArrayList<String> = ArrayList()
listVoz.add("NO")
listVoz.add("YES")
vozList = listVoz
val array = arrayOfNulls<String>(listVoz.size)
showDialogVoz(array = listVoz.toArray(array))
}
}
})
@ -133,6 +139,33 @@ class AjustesFragment : BaseFragment<FragmentAjustesBinding,AjustesViewModel>(Aj
dialog.show()
}
private fun showDialogVoz(array:Array<String>){
val builder = AlertDialog.Builder(this.context)
builder.setTitle(getString(R.string.Seleccionaunsector))
builder.setItems(array) { _, which ->
val selected = array[which]
vozList.forEach {
if (it.equals(selected)){
val editor = prefs!!.edit()
editor.putString(VOZ,it)
editor.apply()
viewModel.ajustesitem.get(3).selected = it
ajustesAdapter!!.notifyDataSetChanged()
return@forEach
}
}
}
val dialog = builder.create()
dialog.show()
}

View File

@ -34,7 +34,7 @@ class AjustesViewModel : BaseViewModel() {
fun inititializeDefaultAjusts(sectorDescrip: String,sectorFk : Int, warehouseFk : Int) {
fun inititializeDefaultAjusts(sectorDescrip: String,sectorFk : Int, warehouseFk : Int,vozDescrip:String) {
_ajustesitem.add(
AjustesItemVO(0,
"Sector",
@ -60,7 +60,7 @@ class AjustesViewModel : BaseViewModel() {
_ajustesitem.add(
AjustesItemVO(3,
"Voz",
"",
vozDescrip,
0,
0)
)

View File

@ -6,6 +6,7 @@ import android.content.SharedPreferences
import android.graphics.drawable.Drawable
import android.media.MediaPlayer
import android.os.Bundle
import android.speech.SpeechRecognizer
import android.util.Log
import android.view.View
import android.view.inputmethod.EditorInfo
@ -51,6 +52,7 @@ class CollectionFragment(
private var sectorFk = ""
private var warehouseFk = ""
private var token = ""
private var voz = ""
private var sales:List<SaleVO> = listOf()
private var saleAdapter:SaleAdapter? = null
private var lm : LinearLayoutManager? = null
@ -75,6 +77,11 @@ class CollectionFragment(
private var myKM: KeyguardManager? = null
private var state = 0
private var mIsListening = false
private var placementPicked:PlacementVO? = null
companion object {
fun newInstance(collection:CollectionVO,type:String) = CollectionFragment(collection,type)
@ -94,6 +101,7 @@ class CollectionFragment(
sectorFk = prefs.getInt(SECTORFK,1).toString()
token = prefs.getString(TOKEN,"").toString()
warehouseFk = prefs.getInt(WAREHOUSEFK,1).toString()
voz = prefs.getString(VOZ,"NO").toString()
mperror = MediaPlayer.create((activity as MainActivity),R.raw.error)
mpok = MediaPlayer.create((activity as MainActivity),R.raw.ok)
if (collection.tickets.isEmpty()){
@ -121,6 +129,10 @@ class CollectionFragment(
toolbar_title.text = "collectionTicket_get"
setToolBar()
setEvents()
if (type == SACADOR && voz != "NO"){
setSpeak()
}
if (collection.tickets.isNotEmpty()){
createCollectionList()
}
@ -160,7 +172,9 @@ class CollectionFragment(
}
private fun scanRequest(){
scan_input.requestFocus()
if (scan_input != null) {
scan_input.requestFocus()
}
hideKeyboards()
}
@ -194,7 +208,9 @@ class CollectionFragment(
}
private fun hideKeyboards(){
requireActivity().hideKeyboard()
try{
requireActivity().hideKeyboard()
}catch (e:Exception){}
}
override fun observeViewModel() {
@ -291,15 +307,28 @@ class CollectionFragment(
//CREATE LIST
private fun createCollectionList(){
state = 0
if (type == SACADOR && voz != "NO"){
// initialize()
speak("Colección cargada, diga listo para empezar.")
}
toolbar_title.text = collection.collectionFk
splash_progress.visibility = View.GONE
var salesList:ArrayList<SaleVO> = ArrayList()
tickets = ArrayList()
collection.tickets.forEach { ticket ->
ticket.sales.forEach {saleVO ->
salesList.add(saleVO)
if (tickets.firstOrNull { it == saleVO.ticketFk}.isNullOrEmpty())
tickets.add(saleVO.ticketFk)
if (type == SACADOR && saleVO.quantity != "0"){
salesList.add(saleVO)
if (tickets.firstOrNull { it == saleVO.ticketFk}.isNullOrEmpty())
tickets.add(saleVO.ticketFk)
}else if (type == CONTROLADOR){
salesList.add(saleVO)
if (tickets.firstOrNull { it == saleVO.ticketFk}.isNullOrEmpty())
tickets.add(saleVO.ticketFk)
}
}
}
@ -351,6 +380,7 @@ class CollectionFragment(
setScrollListener(lm!!)
changeInitTicketState()
}
private fun setScrollListener(lm: LinearLayoutManager){
@ -362,6 +392,8 @@ class CollectionFragment(
})
}
//SEARCH AND MARK
private fun findSale(txtscan:String){
goBack = false
@ -372,27 +404,30 @@ class CollectionFragment(
for (saleVO in sales) {
if(saleVO.isPrepared != "1" && saleVO.isPreviousPrepared != "1"){
//1- Por itemFk
if (txtscan == saleVO.itemFk){
/* if (txtscan == saleVO.itemFk){
mpok!!.start()
isOk = true
markLine(index,type)
break
}
}*/
//2- Por carro
var shelvingIndex = 0
for (placementVO in saleVO.placements){
if (txtscan.toUpperCase() == placementVO.shelving.toUpperCase() && placementVO.visible != "(0)"){
mpok!!.start()
isOk = true
showShelving(index,shelvingIndex)
isBreak = true
break
if (saleVO.placements != null){
var shelvingIndex = 0
for (placementVO in saleVO.placements){
if (placementVO.shelving != null && placementVO.visible != null && txtscan.toUpperCase() == placementVO.shelving.toUpperCase() && placementVO.visible != "(0)"){
mpok!!.start()
isOk = true
showShelving(index,shelvingIndex)
isBreak = true
break
}
shelvingIndex+=1
}
shelvingIndex+=1
if (isBreak) break
}
if (isBreak) break
//3- Por barcode
saleVO.Barcodes.forEach { barcode ->
/*saleVO.Barcodes.forEach { barcode ->
if (txtscan == barcode){
mpok!!.start()
isOk = true
@ -400,7 +435,7 @@ class CollectionFragment(
isBreak = true
}
}
if (isBreak) break
if (isBreak) break*/
}
index += 1
}
@ -528,6 +563,7 @@ class CollectionFragment(
}
private fun markLine(position:Int,newType: String){
state = 0
if (type == SACADOR){
sales[position].isPrepared = if (sales[position].isPrepared == "1") "0" else "1"
if (sales[position].isPrepared == "1"){
@ -546,12 +582,17 @@ class CollectionFragment(
private fun setListPosition(position:Int,isFromBack:Boolean){
storedPosition = position
if (type == SACADOR){
fragment_sacador_collections.addViewObserver {
lm!!.scrollToPositionWithOffset(position,0)
if (fragment_sacador_collections != null){
fragment_sacador_collections.addViewObserver {
lm!!.scrollToPositionWithOffset(position,0)
}
}
}else if (isFromBack){
fragment_sacador_collections.addViewObserver {
lm!!.scrollToPositionWithOffset(position,0)
if (fragment_sacador_collections != null) {
fragment_sacador_collections.addViewObserver {
lm!!.scrollToPositionWithOffset(position, 0)
}
}
}
@ -569,7 +610,7 @@ class CollectionFragment(
}
private fun unMarkLine(position: Int,newType: String){
state = 0
if (sales[position].isPrepared == "1"){
customDialog.setTitle("Desmarcar linea").setDescription("Vas a desmarcar la linea: "+sales[position].itemFk+ " ¿Estás seguro?").setOkButton("Desmarcar"){
sales[position].isPrepared = "0"
@ -642,9 +683,9 @@ class CollectionFragment(
try {
customDialogList.setTitle("$shelving($item) $total de $longName").setOkButton("Coger") {
if (customDialogList.getValueTwo().isNotEmpty()) {
if (customDialogList.getValue().toBigInteger() > total.toBigInteger()) {
if (isNumber(customDialogList.getValue()) && customDialogList.getValue().toInt() > total.toInt()) {
"La cantidad supera a la disponible".toast(requireContext())
} else {
} else if (isNumber(customDialogList.getValue())) {
if (checkItemScan(customDialogList.getValueTwo())) {
onQuantityOfShelvingSelected(itemShelvingFk)
mpok?.start()
@ -661,6 +702,8 @@ class CollectionFragment(
}
scanRequest()
hideKeyboards()
}else{
"cantidad introducida erronea".toast(requireContext())
}
} else {
@ -675,21 +718,22 @@ class CollectionFragment(
}.setHintValue("Cantidad que coges:").setValue(total).setHintValueTwo("Escanea item")
.setValueTwo("").show()
}catch (e:Exception){}
try{
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)
})
}catch (e:Exception){}
try {
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()) {
try {
if (customDialogList.getValue().toBigInteger() > total.toBigInteger()) {
if (isNumber(customDialogList.getValue()) && customDialogList.getValue().toInt() > total.toInt()) {
"La cantidad supera a la disponible".toast(requireContext())
} else {
} else if (isNumber(customDialogList.getValue())) {
if (checkItemScan(customDialogList.getValueTwo())) {
onQuantityOfShelvingSelected(itemShelvingFk)
mpok?.start()
@ -703,7 +747,10 @@ class CollectionFragment(
code = customDialogList.getValueTwo()
)
customDialogList.dismiss()
scanRequest()
}
}else{
"cantidad introducida erronea".toast(requireContext())
}
}catch (e:Exception){
@ -756,27 +803,39 @@ class CollectionFragment(
return false
}
private fun onQuantityOfShelvingSelected(itemShelvingFk:String){
private fun onQuantityOfShelvingSelected(itemShelvingFk:String,quantity:String = "0"){
//1 - MODIFICAR CANTIDAD DEL CARRO
try {
val shelvingVisible = sales[storedPosition].placements[storedShelvingPosition].visible.substring(1,sales[storedPosition].placements[storedShelvingPosition].visible.indexOf(")"))
sales[storedPosition].placements[storedShelvingPosition].visible =
"("+(shelvingVisible.toInt() - customDialogList.getValue().toInt()).toString()+")"
if (quantity == "0"){
sales[storedPosition].placements[storedShelvingPosition].visible = "("+(shelvingVisible.toInt() - customDialogList.getValue().toInt()).toString()+")"
}else{
sales[storedPosition].placements[storedShelvingPosition].visible = "("+(shelvingVisible.toInt() - quantity.toInt()).toString()+")"
}
viewModel.itemShelvingSaleSupplyAdd(
usuario = user,
password = password,
itemShelvingFk = itemShelvingFk,
saleFk = sales[storedPosition].saleFk,
quantity = customDialogList.getValue()
quantity = if (quantity != "0") quantity else customDialogList.getValue()
)
}catch (e:Exception){}
//2- MODIFICAR EL PICKED DEL SALE
try{
sales[storedPosition].pickedQuantity = (sales[storedPosition].pickedQuantity.toInt() + customDialogList.getValue().toInt()).toString()
if (quantity == "0") {
sales[storedPosition].pickedQuantity =
(sales[storedPosition].pickedQuantity.toInt() + customDialogList.getValue()
.toInt()).toString()
}else{
sales[storedPosition].pickedQuantity =
(sales[storedPosition].pickedQuantity.toInt() +quantity
.toInt()).toString()
}
}catch (e:Exception){}
//3- MARCAR LINEA
@ -1278,7 +1337,164 @@ class CollectionFragment(
customDialogList.getRecyclerView().layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
}
fun isNumber(num:String) : Boolean{
var numberInt = 0
try{
numberInt = num.toInt()
return true
}catch (e: Exception){
return false
}
}
//VOZ
override fun onResults(results: Bundle) {
super.onResults(results)
Log.i("Speech", "onResults")
val matches = results
.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION)
if (matches != null) {
Log.i("RESPUESTA", matches[0])
mIsListening = false
mSpeechRecognizer!!.cancel()
getText(matches[0])
}
}
private fun getText(text:String){
val pos = checkText(text)
when (pos) {
NEW_COLLECTION -> {
}
CANCEL -> {
}
LISTO -> {
state += 1
speakOrder()
}
VOLVER -> {
}
REPITE -> {
speakOrder()
}
OTRO -> {
speak("Orden no registrada")
}
FALTA -> {
speak("Orden no registrada")
}
else -> speak("Orden no registrada")
}
}
private fun speakOrder(){
if (type == SACADOR){
if (state == 0){
speak("Colección cargada, diga listo para empezar.")
}else{
var index = 0
for (sale in sales){
if (sale.isPrepared == "0" && sale.isPreviousPrepared == "0" && sale.isControlled == "0"){
if (state == 1){
//cantar pasillo
if (sale.placements.size > 0){
var placementIndex = 0
for (placement in sale.placements){
var visible = placement.visible
visible = visible.replace("(","")
visible = visible.replace(")","")
var quantityVisible = 0
try {
quantityVisible = visible.toInt()
}catch (e:Exception){}
if (quantityVisible > 0){
val pasillo = placement.placement.subSequence(0,sale.placements[0].placement.indexOf("-")).toString()
val sector = placement.placement.subSequence(sale.placements[0].placement.indexOf("-")+1,sale.placements[0].placement.length).toString()
var letras:ArrayList<Char> = ArrayList()
val carro = placement.shelving
var carroSeparate:StringBuilder = StringBuilder("")
for (l in carro){
carroSeparate.append(l)
carroSeparate.append(" ")
}
try {
speak("Pasillo "+pasillo.toInt()+ ", Sector "+sector.toInt()+ ", "+carroSeparate.toString())
}catch (e:Exception){
speak("Pasillo "+pasillo+ " Sector "+sector+" Carro "+carro)
}
placementPicked = placement
storedShelvingPosition = placementIndex
break
}
placementIndex += 1
}
}else{
speak("El item "+sale.itemFk+" no se encuentra disponible. Se necesita actuación manual.")
}
}else if (state == 2){
//cantar articulo
try {
val item = sale.itemFk
val cantidad = sale.quantity.toInt() - sale.pickedQuantity.toInt()
speak("Item "+item.toInt()+ ", Cantidad: "+cantidad)
}catch (e:Exception){
speak("Se necesita actuación manual")
}
}else if (state == 3){
//marcar linea
var visible = placementPicked!!.visible
visible = visible.replace("(","")
visible = visible.replace(")","")
var quantityVisible = 0
try {
quantityVisible = visible.toInt()
}catch (e:Exception){}
var needPicked = 0
try {
needPicked = sale.quantity.toInt() - sale.pickedQuantity.toInt()
}catch (e:Exception){}
storedPosition = index
if (quantityVisible < needPicked){
onQuantityOfShelvingSelected(itemShelvingFk = placementPicked!!.itemShelvingSaleFk,quantity = quantityVisible.toString())
}else{
onQuantityOfShelvingSelected(itemShelvingFk = placementPicked!!.itemShelvingSaleFk,quantity = needPicked.toString())
}
state = 0
speak("Acción registrada. Diga listo para continuar")
}
break
}
index += 1
}
if (index >= sales.size){
speak("Colección completada. Muchas gracias")
}
}
}
}
override fun onDestroy() {
cancelSpeech()
super.onDestroy()
}
}

View File

@ -30,6 +30,7 @@ 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.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.presacador.fragment.PreSacadorFragment
import es.verdnatura.presentation.view.feature.reposicion.fragment.ReposicionFragment
import es.verdnatura.presentation.view.feature.sacador.fragment.SacadorFragment
import es.verdnatura.presentation.view.feature.sacador.model.CollectionVO
import es.verdnatura.presentation.view.feature.shelvingparking.fragment.ShelvingParkingFragment
@ -168,6 +169,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>() , OnPasillerosItemClick
"Pre Sacador" -> {
addFragmentOnTop(PreSacadorFragment.newInstance())
}
"Reposición" -> {
addFragmentOnTop(ReposicionFragment.newInstance())
}
"Consultar artículo" -> {
addFragmentOnTop(ItemCardFragment.newInstance(entryPoint))
}

View File

@ -41,6 +41,8 @@ class PasilleroFragment : BaseFragment<FragmentPasilleroBinding,PasilleroViewMod
}
override fun observeViewModel() {
with(viewModel){
pasilleros_items.adapter = PasillerosAdapter(pasillerositem,pasillerosItemClickListener!!)

View File

@ -20,6 +20,12 @@ class PasilleroViewModel : BaseViewModel() {
"Pre Sacador",R.string.PreSacador)
)
_pasillerositem.add(
PasillerosItemVO(7,
R.drawable.ic_baseline_all_inbox_24,
"Reposición",R.string.reposicion)
)
_pasillerositem.add(
PasillerosItemVO(0,
R.drawable.ic_loyalty_black_24dp,

View File

@ -9,6 +9,7 @@ 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.pasillero.model.PasillerosItemVO
@ -19,6 +20,7 @@ import es.verdnatura.presentation.view.feature.sacador.model.SaleVO
class PreSacadorAdapter (
private val items: List<PreSacadorItemVO>,
private val onPasillerosItemClickListener: OnPasillerosItemClickListener,
private val onQuantityClick: OnQuantityClickListener,
private val onSaleClickListener: OnSaleClickListener
): RecyclerView.Adapter<PreSacadorAdapter.AjustesItemHolder> () {
var context: Context? = null
@ -64,6 +66,19 @@ class PreSacadorAdapter (
onPasillerosItemClickListener.onPasillerosItemClickListener(PasillerosItemVO(title = "Consultar artículo"),sale.itemFk)
}
itemArticleQuantity.setOnClickListener {
onQuantityClick.onQuantityClick(sale)
}
itemArticleQuantityPicked.setOnClickListener {
onQuantityClick.onQuantityClick(sale)
}
if (sale.quantity == sale.pickedQuantity){
sale.isPreviousPrepared = "1"
}else{
sale.isPreviousPrepared = "0"
}
//SEMAFORO
if (sale.isPreviousPrepared == "1"){

View File

@ -21,6 +21,7 @@ import es.verdnatura.presentation.common.*
import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.component.CustomDialogInput
import es.verdnatura.presentation.view.component.CustomDialogList
import es.verdnatura.presentation.view.component.CustomDialogThreeButtons
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
@ -57,6 +58,9 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
private var listPlacementSupply:ArrayList<BarcodeVO> = ArrayList()
private var placementSupplyAdapter : BarcodeAdapter? = null
private lateinit var customDialogInput: CustomDialogInput
private lateinit var customDialogThreeButtons: CustomDialogThreeButtons
private var token = ""
private var ticketFk = ""
override fun onAttach(context: Context) {
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
@ -68,6 +72,7 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
user = prefs.getString(USER,"").toString()
password = prefs.getString(PASSWORD,"").toString()
sectorFk = prefs.getInt(SECTORFK,1).toString()
token = prefs.getString(TOKEN,"").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)
@ -79,6 +84,7 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
customDialog = CustomDialog(requireContext())
customDialogList = CustomDialogList(requireContext())
customDialogInput = CustomDialogInput(requireContext())
customDialogThreeButtons = CustomDialogThreeButtons(requireContext())
activity!!.main_bottom_navigation.visibility = View.GONE
splash_progress.visibility = View.GONE
toolbar_title.text = "ticketToPrePrepare"
@ -103,6 +109,7 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
}else{
if (scan_input.text.length > 6){
//es ticket
ticketFk = scan_input.text.toString()
searchTicket(scan_input.text.toString())
}else{
//es sale
@ -196,7 +203,16 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
}
lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
saleAdapter = PreSacadorAdapter(sales,pasillerosItemClickListener!!,object :
saleAdapter = PreSacadorAdapter(sales,pasillerosItemClickListener!!,object: OnQuantityClickListener{
override fun onQuantityClick(sale: SaleVO) {
sales.forEachIndexed { index, saleVO ->
if (saleVO.idMovimiento == sale.saleFk){
showQuantityDialog(index)
}
}
}
},object :
OnSaleClickListener {
override fun onSaleClick(sale: SaleVO) {
sales.forEachIndexed { index, saleVO ->
@ -235,7 +251,7 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
private fun setTotalLines(){
var totalMark = 0
sales.forEach {
if (it.quantity == it.picked)
if (it.saldo == it.picked)
totalMark += 1
}
toolbar_title.text = ticket
@ -366,7 +382,7 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
splash_progress.visibility = View.VISIBLE
var quantityGet = "0"
try{
quantityGet = (sales[position].quantity - sales[position].picked).toString()
quantityGet = (sales[position].saldo - sales[position].picked).toString()
}catch (e:Exception){}
viewModel.itemPlacementSupplyAiming(
usuario = user,
@ -579,7 +595,9 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
}
private fun scanRequest(){
scan_input.requestFocus()
if (scan_input != null) {
scan_input.requestFocus()
}
hideKeyboards()
}
@ -616,4 +634,214 @@ class PreSacadorFragment : BaseFragment<FragmentPreSacadorBinding,PreSacadorView
}.show()
}
//FALTAS / BASURA / SPLIT
private fun showQuantityDialog(position:Int) {
customDialogThreeButtons.setDescription(getString(R.string.txtnuevacantidad)).setValue("")
.setOkButton(getString(R.string.Faltas)){
if (customDialogThreeButtons.getValue().trim().isNullOrEmpty()){
getString(R.string.Indicanuevacantidad).toast(requireContext())
}else{
trash(position,customDialogThreeButtons.getValue())
scanRequest()
customDialogThreeButtons.dismiss()
}
}.setOkButtonTwo(getString(R.string.BasuraRechazar)){
if (customDialogThreeButtons.getValue().trim().isNullOrEmpty()){
getString(R.string.Indicanuevacantidad).toast(requireContext())
}else{
missing(position,customDialogThreeButtons.getValue())
scanRequest()
customDialogThreeButtons.dismiss()
}
}.setOkButtonThree(getString(R.string.Reject)){
if (customDialogThreeButtons.getValue().trim().isNullOrEmpty()){
getString(R.string.Indicanuevacantidad).toast(requireContext())
}else{
reject(position,customDialogThreeButtons.getValue())
scanRequest()
customDialogThreeButtons.dismiss()
}
}.setOkButtonFour("Split"){
if (customDialogThreeButtons.getValue().trim().isNullOrEmpty()){
getString(R.string.Indicanuevacantidad).toast(requireContext())
}else{
split(position,customDialogThreeButtons.getValue())
scanRequest()
customDialogThreeButtons.dismiss()
}
}.setOkButtonAdd(getString(R.string.Agregar)){
if (customDialogThreeButtons.getValue().trim().isNullOrEmpty()){
getString(R.string.Indicanuevacantidad).toast(requireContext())
}else{
increaseQuantity(position,customDialogThreeButtons.getValue())
scanRequest()
customDialogThreeButtons.dismiss()
}
}.setKoButton("Cancelar"){
scanRequest()
customDialogThreeButtons.dismiss()
}.show()
}
private fun split(position: Int,quantity:String){
var totalQuantity: Int = 0
try {
totalQuantity = sales[position].saldo.toInt() - quantity.toInt()
}catch (e:Exception){}
viewModel.saleMove(
usuario = user,
password = password,
saleFk = sales[position].idMovimiento,
quantity = totalQuantity.toString(),
originalQuantity = sales[position].quantity.toString()
)
//sales[position].originalQuantity = quantity
try{
sales[position].saldo = quantity.toInt()
}catch (e:Exception){
sales[position].saldo = 0
}
//sales[position].startQuantity = quantity
if (quantity == "0")
markLine(position)
saleAdapter!!.notifyDataSetChanged()
//enviar mensaje a salix
val ticket = "[" + ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + ticketFk + "/summary)"
val message = "Se ha enviado a Split el articulo "+sales[position].itemFk+" del ticket "+ticket
viewModel.sendChekingPresence(token = token,workerId = sales[position].trabajador,message = message)
}
private fun trash(position: Int,quantity:String){
var totalQuantity: Int = 0
try {
totalQuantity = sales[position].saldo.toInt() - quantity.toInt()
}catch (e:Exception){}
viewModel.collectionMissingTrash(
usuario = user,
password = password,
saleFk = sales[position].idMovimiento,
quantity = totalQuantity.toString(),
warehouseFk = warehouseFk,
type = "FALSE",
originalQuantity = quantity
)
//sales[position].originalQuantity = quantity
try{
sales[position].saldo = quantity.toInt()
}catch (e:Exception){
sales[position].saldo = 0
}
//sales[position].startQuantity = quantity
saleAdapter!!.notifyDataSetChanged()
if (quantity == "0")
markLine(position)
//enviar mensaje a salix
val ticket = "[" + ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + ticketFk + "/summary)"
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].trabajador,message = message)
}
private fun missing(position: Int,quantity:String){
var totalQuantity: Int = 0
try {
totalQuantity = sales[position].saldo.toInt() - quantity.toInt()
}catch (e:Exception){}
viewModel.collectionMissingTrash(
usuario = user,
password = password,
saleFk = sales[position].idMovimiento,
quantity = totalQuantity.toString(),
warehouseFk = warehouseFk,
type = "TRUE",
originalQuantity = quantity
)
//sales[position].originalQuantity = quantity
try{
sales[position].saldo = quantity.toInt()
}catch (e:Exception){
sales[position].saldo = 0
}
//sales[position].startQuantity = quantity
if (quantity == "0")
markLine(position)
saleAdapter!!.notifyDataSetChanged()
//enviar mensaje a salix
val ticket = "[" + ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + ticketFk + "/summary)"
val message = "Se ha enviado a Basura "+ totalQuantity +" del articulo "+sales[position].itemFk+" ticket "+ticket
viewModel.sendChekingPresence(token = token,workerId = sales[position].trabajador,message = message)
}
private fun reject(position: Int,quantity:String){
var totalQuantity: Int = 0
try {
totalQuantity = sales[position].saldo.toInt() - quantity.toInt()
}catch (e:Exception){}
viewModel.collectionMissingTrash(
usuario = user,
password = password,
saleFk = sales[position].idMovimiento,
quantity = totalQuantity.toString(),
warehouseFk = warehouseFk,
type = "reject",
originalQuantity = quantity
)
//enviar mensaje a salix
val ticket = "[" + ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + ticketFk + "/summary)"
val message = "Se ha modificado la cantidad original "+sales[position].saldo+" del artículo "+sales[position].itemFk+" a nueva cantidad: "+ quantity +" del ticket "+ticket
viewModel.sendChekingPresence(token = token,workerId = sales[position].trabajador,message = message)
try{
sales[position].saldo = quantity.toInt()
}catch (e:Exception){
sales[position].saldo = 0
}
//sales[position].startQuantity = quantity
saleAdapter!!.notifyDataSetChanged()
if (quantity == "0")
markLine(position)
}
private fun increaseQuantity(position:Int,quantity:String){
viewModel.collectionIncreaseQuantity(
usuario = user,
password = password,
saleFk = sales[position].idMovimiento,
quantity = quantity
)
try {
//enviar mensaje a salix
val ticket = "[" + ticketFk + "](https://salix.verdnatura.es/#!/ticket/" + ticketFk + "/summary)"
val message = "Se ha modificado la cantidad original "+sales[position].saldo+" del artículo "+sales[position].itemFk+" a nueva cantidad: "+ quantity +" del ticket "+ticket
viewModel.sendChekingPresence(token = token,workerId = sales[position].trabajador,message = message)
try{
sales[position].saldo = quantity.toInt()
}catch (e:Exception){
sales[position].saldo = 0
}
}catch (e:Exception){}
saleAdapter?.notifyDataSetChanged()
}
}

View File

@ -1,7 +1,9 @@
package es.verdnatura.presentation.view.feature.presacador.fragment
import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.GetLoginUserCase
import es.verdnatura.domain.GetPreSacadorUseCase
import es.verdnatura.domain.GetSacadorControladorUserCase
import es.verdnatura.domain.GetUbicadorUserCase
@ -18,6 +20,7 @@ class PreSacadorViewModel : BaseViewModel() {
private val getPreSacadorUseCase: GetPreSacadorUseCase = GetPreSacadorUseCase()
private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase()
private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase()
private val getLoginUserCase: GetLoginUserCase = GetLoginUserCase()
private val _salesList by lazy { MutableLiveData<List<PreSacadorItemVO>>() }
val salesList: LiveData<List<PreSacadorItemVO>>
@ -35,6 +38,10 @@ class PreSacadorViewModel : BaseViewModel() {
val responseCode: LiveData<ResponseItemVO>
get() = _responseCode
private val _responseIncQuantity by lazy { MutableLiveData<ResponseItemVO>() }
val responseIncQuantity: LiveData<ResponseItemVO>
get() = _responseIncQuantity
fun ticketToPrePrepare(usuario:String,password:String,ticketFk:String,sectorFk:String){
getPreSacadorUseCase.ticketToPrePrepare(usuario,password,ticketFk,sectorFk).enqueue(object :
@ -173,4 +180,67 @@ class PreSacadorViewModel : BaseViewModel() {
}
})
}
fun saleMove(usuario:String,password:String,saleFk: String,quantity: String,originalQuantity : String){
getSacadorControladorUserCase.saleMove(usuario,password,saleFk,quantity,originalQuantity).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 saleMove")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun collectionMissingTrash(usuario:String,password:String,saleFk: String,quantity: String,type:String,warehouseFk:String,originalQuantity: String){
getSacadorControladorUserCase.collectionMissingTrash(usuario,password,saleFk,quantity,type,warehouseFk,originalQuantity).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()!!)
}
}
})
}
fun collectionIncreaseQuantity(usuario:String,password:String,saleFk: String,quantity: String){
getSacadorControladorUserCase.collectionIncreaseQuantity(usuario,password,saleFk,quantity).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_responseIncQuantity.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_responseIncQuantity.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada collectionIncreaseQuantity")
}else{
_responseIncQuantity.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun sendChekingPresence(token:String,workerId:String,message:String){
try{
getLoginUserCase.sendChekingPresence(token,workerId.toInt(),message).enqueue(object : Callback<Boolean>{
override fun onResponse(call: Call<Boolean>, response: Response<Boolean>) {
Log.i("Salix","Mensaje enviado a salix")
}
override fun onFailure(call: Call<Boolean>, t: Throwable) {
Log.i("Salix Error",""+t.message)
}
})
}catch (e:Exception){}
}
}

View File

@ -15,10 +15,30 @@ fun PreSacadorItemVO.toSale() : SaleVO {
line1 = longName,
line2 = if (subName.isNullOrEmpty()) "" else subName,
pickedQuantity = picked.toString(),
workerFk = trabajador,
workerFk = if (trabajador.isNullOrEmpty()) { "0" } else trabajador,
originalQuantity = quantity.toString(),
placements = carros,
agencyName = trabajador
agencyName = if (trabajador.isNullOrEmpty()) { "" } else trabajador
)
}
fun PreSacadorItemVO.toSaleReposicion() : SaleVO {
return SaleVO(
ticketFk = id,
level = "1",
saleFk = idMovimiento,
itemFk = itemFk,
quantity = quantity.toString(),
longName = longName,
isPreviousPrepared = if ((quantity - saldo) == 0) "1" else "0",
line1 = longName,
line2 = if (subName.isNullOrEmpty()) "" else subName,
pickedQuantity = (quantity - saldo).toString(),
workerFk = if (trabajador.isNullOrEmpty()) { "0" } else trabajador,
originalQuantity = quantity.toString(),
placements = carros,
agencyName = if (trabajador.isNullOrEmpty()) { "" } else trabajador
)
}

View File

@ -0,0 +1,103 @@
package es.verdnatura.presentation.view.feature.reposicion.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.pasillero.model.PasillerosItemVO
import es.verdnatura.presentation.view.feature.presacador.adapter.PreSacadorAdapter
import es.verdnatura.presentation.view.feature.presacador.mapper.toSale
import es.verdnatura.presentation.view.feature.presacador.mapper.toSaleReposicion
import es.verdnatura.presentation.view.feature.presacador.model.PreSacadorItemVO
import es.verdnatura.presentation.view.feature.sacador.model.SaleVO
class ReposicionAdapter (
private val items: List<PreSacadorItemVO>,
private val onPasillerosItemClickListener: OnPasillerosItemClickListener,
private val onSaleClickListener: OnSaleClickListener
): RecyclerView.Adapter<ReposicionAdapter.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.toSaleReposicion()
itemRowLayout.visibility = View.GONE
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)
}
if (sale.quantity == sale.pickedQuantity){
sale.isPreviousPrepared = "1"
}else{
sale.isPreviousPrepared = "0"
}
//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
}
}
}
}

View File

@ -0,0 +1,597 @@
package es.verdnatura.presentation.view.feature.reposicion.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 androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import es.verdnatura.R
import es.verdnatura.databinding.ReposicionFragmentBinding
import es.verdnatura.domain.ConstAndValues
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.CustomDialogInput
import es.verdnatura.presentation.view.component.CustomDialogList
import es.verdnatura.presentation.view.component.CustomDialogThreeButtons
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.fragment.PasilleroFragment
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.reposicion.adapter.ReposicionAdapter
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.reposicion_fragment.*
import kotlinx.android.synthetic.main.reposicion_fragment.fragment_sacador_collections
import kotlinx.android.synthetic.main.reposicion_fragment.scan_input
import kotlinx.android.synthetic.main.reposicion_fragment.splash_progress
import kotlinx.android.synthetic.main.toolbar.*
class ReposicionFragment : BaseFragment<ReposicionFragmentBinding, ReposicionViewModel>(
ReposicionViewModel::class){
private var user = ""
private var password = ""
private var sectorFk = ""
private var warehouseFk = ""
private var pasillerosItemClickListener: OnPasillerosItemClickListener? = null
private lateinit var customDialog: CustomDialog
private lateinit var customDialogList: CustomDialogList
private lateinit var customDialogInput: CustomDialogInput
private lateinit var customDialogThreeButtons: CustomDialogThreeButtons
private var sales:ArrayList<PreSacadorItemVO> = ArrayList()
private var lm : LinearLayoutManager? = null
private var saleAdapter: ReposicionAdapter? = null
var mperror: MediaPlayer? = null
var mpok: MediaPlayer? = null
private var storedBackPosition : Int = 0
private var storedShelvingPosition:Int = 0
private var storedPosition: Int = 0
private var listPlacementSupply:ArrayList<BarcodeVO> = ArrayList()
private var itemShelvingFkStored : String = ""
private var placementSupplyAdapter : BarcodeAdapter? = null
private var goBack:Boolean = false
private var goBack2:Boolean = false
companion object {
fun newInstance() = ReposicionFragment()
}
override fun onAttach(context: Context) {
if (context is OnPasillerosItemClickListener) pasillerosItemClickListener = context
super.onAttach(context)
}
override fun getLayoutId(): Int = R.layout.reposicion_fragment
override fun init() {
customDialog = CustomDialog(requireContext())
customDialogList = CustomDialogList(requireContext())
customDialogInput = CustomDialogInput(requireContext())
customDialogThreeButtons = CustomDialogThreeButtons(requireContext())
activity!!.main_bottom_navigation.visibility = View.GONE
splash_progress.visibility = View.GONE
toolbar_title.text = "itemPlacementSupplyGetOrder"
setToolBar()
setEvents()
super.init()
}
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 onPause() {
goBack = true
goBack2 = true
super.onPause()
}
private fun setEvents(){
backButton.setOnClickListener {
activity!!.onBackPressed()
}
btn_obtener.setOnClickListener {
splash_progress.visibility = View.VISIBLE
viewModel.itemPlacementSupplyGetOrder(usuario = user,password = password,sectorFk = sectorFk)
}
btn_cancelar.setOnClickListener {
customDialog.setTitle("Confirmar").setDescription("¿Estás seguro de cerrar el pedido?").setKoButton("Cerrar"){
scanRequest()
customDialog.dismiss()
}.setOkButton("Cerrar"){
splash_progress.visibility = View.VISIBLE
if (sales.count() > 0){
viewModel.itemPlacementSupplyCloseOrder(usuario = user,password = password,id = sales[0].id,quantity = sales[0].quantity.toString())
}
customDialog.dismiss()
}.show()
}
//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 (sales.count() > 0 && sales[0].saldo == 0){
"Pedido completado".toast(requireContext())
}else{
findSale(scan_input.text.toString())
}
}
scan_input.setText("")
hideKeyboards()
return@setOnEditorActionListener true
}
true
}
hideKeyboards()
//LISTA =========
collection_swipe.setOnRefreshListener {
splash_progress.visibility = View.VISIBLE
viewModel.itemPlacementSupplyGetOrder(usuario = user,password = password,sectorFk = sectorFk)
collection_swipe.isRefreshing = false
}
}
private fun hideKeyboards(){
requireActivity().hideKeyboard()
}
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
})
responseClose.observe(viewLifecycleOwner, Observer {
splash_progress.visibility = View.GONE
sales.clear()
saleAdapter!!.notifyDataSetChanged()
btn_cancelar.visibility = View.GONE
})
}
super.observeViewModel()
}
private fun createSaleList(salesList : List<PreSacadorItemVO>){
splash_progress.visibility = View.GONE
if (salesList.isNullOrEmpty()){
customDialog.setTitle("Reposición").setDescription("No existen pedidos para reponer").setKoButton("Cancelar"){
if (sales.count()>0){
sales.clear()
saleAdapter!!.notifyDataSetChanged()
}
customDialog.dismiss()
}.show()
scan_input.visibility = View.GONE
btn_cancelar.visibility = View.GONE
}else if(salesList.count() > 0 && salesList[0].saldo == 0){
"Pedido completado".toast(requireContext())
scan_input.visibility = View.GONE
btn_cancelar.visibility = View.GONE
}else{
scan_input.visibility = View.VISIBLE
btn_cancelar.visibility = View.VISIBLE
sales = ArrayList()
salesList.forEach {
sales.add(it)
}
lm = LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false)
saleAdapter = ReposicionAdapter(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
}
}
//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())
}
}
//SHELVINGS
private fun showShelving(position:Int,shelvingPosition:Int){
storedShelvingPosition = shelvingPosition
storedPosition = position
splash_progress.visibility = View.VISIBLE
var quantityGet = "0"
try{
quantityGet = (sales[position].saldo - 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.itemShelvingPlacementSupplyAdd(
usuario = user,
password = password,
itemShelvingFk = itemShelvingFk,
itemPlacementSupplyFk = sales[storedPosition].id,
quantity = customDialogList.getValue()
)
}catch (e:Exception){}
//2- MODIFICAR EL PICKED DEL SALE
try{
sales[storedPosition].saldo = sales[storedPosition].saldo - customDialogList.getValue().toInt()
}catch (e:Exception){}
//3- MARCAR LINEA
markLine(storedPosition)
}
//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){
}else if (item == iconParking){
pasillerosItemClickListener?.onPasillerosItemClickListener(PasillerosItemVO(title = "Parking"),"")
}
}
})
toolbar_icons.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
}
private fun scanRequest(){
scan_input.requestFocus()
hideKeyboards()
}
private fun checkItemScan(valueToCheck:String):Boolean{
val saleToCheck = sales[storedPosition]
return saleToCheck.itemFk == valueToCheck
}
private fun showErrorMessage(text:String){
customDialog.setTitle("Error al marcar la linea").setDescription(text).setKoButton("Cerrar"){
customDialog.dismiss()
}.show()
}
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
}
}
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()
/*viewModel.saleTrackingDel(
usuario = user,
password = password,
saleFk = sales[position].idMovimiento
)*/
scanRequest()
customDialog.dismiss()
}.setKoButton("Cancelar"){
scanRequest()
customDialog.dismiss()
}.show()
}
}
private fun markLine(position:Int){
saleAdapter!!.notifyDataSetChanged()
}
}

View File

@ -0,0 +1,149 @@
package es.verdnatura.presentation.view.feature.reposicion.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 ReposicionViewModel : BaseViewModel() {
private val getPreSacadorUseCase: GetPreSacadorUseCase = GetPreSacadorUseCase()
private val getUbicadorUserCase: GetUbicadorUserCase = GetUbicadorUserCase()
private val getSacadorControladorUserCase: GetSacadorControladorUserCase = GetSacadorControladorUserCase()
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 _responseClose by lazy { MutableLiveData<ResponseItemVO>() }
val responseClose: LiveData<ResponseItemVO>
get() = _responseClose
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 itemPlacementSupplyGetOrder(usuario:String,password:String,sectorFk:String){
getPreSacadorUseCase.itemPlacementSupplyGetOrder(usuario,password,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 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 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 itemShelvingPlacementSupplyAdd(usuario:String,password:String,itemShelvingFk:String,itemPlacementSupplyFk:String,quantity:String){
getSacadorControladorUserCase.itemShelvingPlacementSupplyAdd(usuario,password,itemShelvingFk,itemPlacementSupplyFk,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 itemShelvingPlacementSupplyAdd")
}else{
_response.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
fun itemPlacementSupplyCloseOrder(usuario:String,password:String,id:String,quantity:String){
getPreSacadorUseCase.itemPlacementSupplyCloseOrder(usuario,password,id,quantity).enqueue(object : Callback<String>{
override fun onFailure(call: Call<String>, t: Throwable) {
_responseClose.value = ResponseItemVO(isError = true,errorMessage = ""+t.message!!)
}
override fun onResponse(call: Call<String>, response: Response<String>) {
if (response.body() == null){
_responseClose.value = ResponseItemVO(isError = true,errorMessage = "Error en la llamada itemPlacementSupplyCloseOrder")
}else{
_responseClose.value = ResponseItemVO(isError = false,response = response.body()!!)
}
}
})
}
}

View File

@ -178,8 +178,15 @@ class UbicadorFragment(
viewModel.shelvingPark(user,password,shelvingFk,customDialogInput.getValue())
customDialogInput.dismiss()
parking = customDialogInput.getValue()
toolbar_title.text = shelvingFk.toUpperCase() + " P: "+parking+ " E: "+etiquetas
mpok!!.start()
if (toolbar_title != null && shelvingFk != null && parking != null && etiquetas != null){
toolbar_title.text = shelvingFk.toUpperCase() + " P: "+parking+ " E: "+etiquetas
}else{
toolbar_title.text = ""
}
if (mpok != null) {
mpok!!.start()
}
return@setOnEditorActionListener true
}
false
@ -204,10 +211,10 @@ class UbicadorFragment(
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.dismiss()
shelvingFk = customDialogInput.getValue()
toolbar_title.text = shelvingFk.toUpperCase() + " P: "+parking+ " E: "+etiquetas
mpok!!.start()
customDialogInput.dismiss()
return@setOnEditorActionListener true
}
false

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#F7931E"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M19,3L5,3c-1.1,0 -2,0.9 -2,2v7c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM19,9h-4c0,1.62 -1.38,3 -3,3s-3,-1.38 -3,-3L5,9L5,5h14v4zM15,16h6v3c0,1.1 -0.9,2 -2,2L5,21c-1.1,0 -2,-0.9 -2,-2v-3h6c0,1.66 1.34,3 3,3s3,-1.34 3,-3z"/>
</vector>

View File

@ -90,8 +90,7 @@
android:layout_height="wrap_content"
android:paddingTop="@dimen/layout_margin_min"
android:paddingBottom="@dimen/layout_margin_min"
android:background="@color/verdnatura_black"
style="@style/LayoutClickable">
android:background="@color/verdnatura_black">
<!--SEMAFORO=================================================-->
<LinearLayout
android:id="@+id/linearLayout3"
@ -138,8 +137,7 @@
app:layout_constraintEnd_toStartOf="@+id/item_article_quantity_picked"
app:layout_constraintStart_toEndOf="@+id/linearLayout3"
app:layout_constraintTop_toTopOf="parent"
android:maxLines="1"
style="@style/LayoutClickable"/>
android:maxLines="1"/>
<TextView
android:id="@+id/item_article_quantity_picked"
@ -176,8 +174,7 @@
android:textSize="@dimen/h6"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
style="@style/LayoutClickable"/>
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/item_article_quantity_line1"

View File

@ -16,8 +16,7 @@
android:orientation="vertical"
android:padding="@dimen/layout_margin_1"
android:gravity="center"
android:layout_marginEnd="@dimen/layout_margin_min"
style="@style/LayoutClickable">
android:layout_marginEnd="@dimen/layout_margin_min">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

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

View File

@ -0,0 +1,115 @@
<?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"
xmlns:tool="http://schemas.android.com/tools">
<data>
<variable
name="viewModel"
type="es.verdnatura.presentation.view.feature.reposicion.fragment.ReposicionViewModel" />
</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="@string/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"
android:visibility="gone"/>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/collection_swipe"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/btn_obtener"
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>
<Button
android:id="@+id/btn_obtener"
style="@style/DefaultButton"
android:layout_width="0dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="@drawable/btn_orange"
android:text="@string/obtener"
android:textColor="@color/verdnatura_white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btn_cancelar"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/btn_cancelar"
style="@style/DefaultButton"
android:layout_width="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="@drawable/btn_blue"
android:text="Cancelar"
android:textColor="@color/verdnatura_white"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<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>

View File

@ -86,4 +86,6 @@
<string name="Reject">Rechazar</string>
<string name="updatemng">Existe una versión nueva, es recomendable actualizar.</string>
<string name="Actualizar">Actualizar</string>
<string name="reposicion">Reposición</string>
<string name="obtener">Obtener</string>
</resources>

View File

@ -85,4 +85,6 @@
<string name="Reject">Reject</string>
<string name="updatemng">There is a new version, it is recommended to update.</string>
<string name="Actualizar">Update</string>
<string name="reposicion">Replacement</string>
<string name="obtener">Get</string>
</resources>