Функционал механика ч.6

This commit is contained in:
Azat Sagutdinov 2024-06-06 16:48:12 +03:00
parent eea1b4d4f3
commit 5455fef624
13 changed files with 181 additions and 35 deletions

View File

@ -9,6 +9,7 @@ data class DataTech(
val waybill_uuid: String,
val waybill_name: String,
val organization_id: String,
val organization_name: String,
val mechanic_id: String,
val mechanic_name: String,
val result_id: String,

View File

@ -53,7 +53,7 @@ class TechListAdapter(
fun bind(list: DataTechCheckup) {
carName.text = list.vehicle_name
time.text = list.datetime
time.text = list.datetime_
//fio.text = list.fio
status.text = list.exam_state_name
/* eye.setImageDrawable(

View File

@ -5,7 +5,10 @@ import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import com.google.gson.Gson
import kotlinx.android.synthetic.main.fragment_medical_checkup.*
import kotlinx.android.synthetic.main.fragment_tech_list.*
import kotlinx.android.synthetic.main.fragment_tech_list.refresh
import ru.tele2med.mobile.R
import ru.tele2med.mobile.presentation.ui.auth.AuthActivity
import ru.tele2med.mobile.presentation.ui.base.BasePresenter
@ -19,7 +22,9 @@ import kotlinx.android.synthetic.main.toolbar_with_help.*
import org.jetbrains.anko.clearTask
import org.jetbrains.anko.intentFor
import org.jetbrains.anko.newTask
import ru.tele2med.mobile.domain.entity.DataTech
import ru.tele2med.mobile.domain.entity.DataTechCheckup
import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.TechCheckupTestsFragment
class TechListFragment : BaseMenuFragment(), TechListView {
@ -92,12 +97,29 @@ class TechListFragment : BaseMenuFragment(), TechListView {
}
recyclerView.addOnScrollListener(scrollListener)
initRecycler()
//setName()
setClickListeners()
}
override fun setRefreshing(flag: Boolean) {
println("setRefreshing = $flag")
refresh.isRefreshing = flag
}
private fun initRecycler() {
println("initRecycler")
refresh.setOnRefreshListener {
println("setOnRefreshListener")
presenter.getCheckups()
}
}
override fun showCheckups(list: List<DataTechCheckup>) {
adapter.submitList(list)

View File

@ -63,6 +63,14 @@ class TechListPresenter(
)
.map(uiConverter::toUiTechCheckups)
.ioToMain()
.doOnSubscribe {
viewState.showLoading()
}
.doAfterTerminate {
viewState.hideLoading()
viewState.setRefreshing(false)
}
.baseLoadingHandle()
.baseHandleErrorSubscribe {
currentCheckups.addAll(it.data)

View File

@ -1,5 +1,7 @@
package ru.tele2med.mobile.presentation.ui.menu.items.tech.list
import com.arellomobile.mvp.viewstate.strategy.AddToEndSingleStrategy
import com.arellomobile.mvp.viewstate.strategy.StateStrategyType
import ru.tele2med.mobile.domain.entity.DataCheckup
import ru.tele2med.mobile.domain.entity.DataTechCheckup
import ru.tele2med.mobile.presentation.ui.base.BaseView
@ -7,4 +9,8 @@ import ru.tele2med.mobile.presentation.ui.base.BaseView
interface TechListView : BaseView {
fun showCheckups(list: List<DataTechCheckup>)
@StateStrategyType(AddToEndSingleStrategy::class)
fun setRefreshing(flag: Boolean)
}

View File

@ -169,7 +169,7 @@ class TechCheckupInfoFragment : BaseMenuFragment(), TechCheckupInfoView {
tvDriverNumber.text = dataTech.vehicle_name
tvDrivers.text = dataTech.mechanic_name
tvOrgName.text = dataTech.organization_id
tvOrgName.text = dataTech.organization_name
tvNumberPL.text = dataTech.waybill_name
tvDatePL.text = dataTech.datetime

View File

@ -15,7 +15,6 @@ import com.arellomobile.mvp.presenter.ProvidePresenter
import com.bumptech.glide.Glide
import com.google.gson.Gson
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.fragment_tech_list.*
import ru.tele2med.mobile.R
import ru.tele2med.mobile.presentation.ui.base.BasePresenter
import ru.tele2med.mobile.presentation.ui.drawer.entity.ScreenType
@ -30,7 +29,6 @@ import org.jetbrains.anko.clearTask
import org.jetbrains.anko.intentFor
import org.jetbrains.anko.newTask
import ru.tele2med.mobile.domain.entity.*
import ru.tele2med.mobile.presentation.router.NavScreens
import ru.tele2med.mobile.presentation.ui.common.EndlessRecyclerViewScrollListener
@ -128,7 +126,7 @@ class TechCheckupTestsFragment : BaseMenuFragment(), TechCheckupTestsView {
override fun setRefreshing(flag: Boolean) {
println("setRefreshing = $flag")
// refresh.isRefreshing = flag
refresh.isRefreshing = flag
}
private fun initRecycler() {

View File

@ -47,6 +47,8 @@ class TechCheckupTestsPresenter(
Log.v("LOG", "it = $it ${it.data.data}")
viewState.showCheckups(it.data.data)
viewState.setRefreshing(false)
}, {
if (it is ApiException) {

View File

@ -10,6 +10,9 @@ import com.arellomobile.mvp.presenter.ProvidePresenter
import com.google.gson.Gson
import kotlinx.android.synthetic.main.fragment_checkup_test.*
import kotlinx.android.synthetic.main.toolbar_with_help.*
import org.jetbrains.anko.clearTask
import org.jetbrains.anko.intentFor
import org.jetbrains.anko.newTask
import ru.tele2med.mobile.R
import ru.tele2med.mobile.domain.entity.CheckupShowList
import ru.tele2med.mobile.domain.entity.DataShow
@ -42,6 +45,9 @@ class TestFragment : BaseMenuFragment(), TestView {
addDrawerToggle()
title = getString(R.string.test_toolbar)
close.visibility = View.VISIBLE
close.setOnClickListener {
activity?.onBackPressed()
}
}
// val args = arguments
@ -75,7 +81,7 @@ class TestFragment : BaseMenuFragment(), TestView {
fillData(data, datacheckupShowList)
actions(data, uniq_id ?: "", dataTech)
actions(data, uniq_id ?: "", dataTech, datacheckupShowList)
}
}
@ -85,7 +91,8 @@ class TestFragment : BaseMenuFragment(), TestView {
tvTestName.text = data.name
tvComment.text = data.comment
tvStatusName.text = checkupShowList?.data?.exam_state_description?: "Вопрос №${data.order+1}"
tvStatusName.text =
checkupShowList?.data?.exam_state_description ?: "Вопрос №${data.order.toInt() + 1}"
}
@ -95,7 +102,17 @@ class TestFragment : BaseMenuFragment(), TestView {
}
private fun actions(data: DataShow, uniq_id: String, dataTech: DataTech) {
private fun actions(
data: DataShow,
uniq_id: String,
dataTech: DataTech,
checkupShowList: CheckupShowList?
) {
skipBtn.setOnClickListener {
presenter.skipTech(uniq_id, dataTech, checkupShowList, data)
}
trueBtn.setOnClickListener {
presenter.setValue(uniq_id, data.uniq_id, data, "1", dataTech)
}
@ -116,7 +133,12 @@ class TestFragment : BaseMenuFragment(), TestView {
private var CHECKUP = "CHECKUP"
fun getInstance(test: DataShow, uniq_id: String, dataTech: DataTech, checkupShowList: CheckupShowList?): TestFragment {
fun getInstance(
test: DataShow,
uniq_id: String,
dataTech: DataTech,
checkupShowList: CheckupShowList?
): TestFragment {
val gson = Gson()
val string: String = gson.toJson(test)
this.TEST = string

View File

@ -29,7 +29,13 @@ class TestPresenter(
}
fun setValue(uniq_id: String, id: String, dataShow: DataShow, value: String, dataTech: DataTech) {
fun setValue(
uniq_id: String,
id: String,
dataShow: DataShow,
value: String,
dataTech: DataTech
) {
var checkup = CheckupData(id, dataShow.name ?: "", value, dataShow.type_id ?: "")
var data: List<CheckupData> = listOf(checkup)
Log.v("LOG", "it checkup = $uniq_id, data = $data")
@ -39,7 +45,7 @@ class TestPresenter(
.ioToMain()
.doOnSubscribe {
Log.v("LOG", "it 2 = $it")
// viewState.showLoading()
// viewState.showLoading()
}
.doAfterTerminate {
viewState.hideLoading()
@ -48,9 +54,8 @@ class TestPresenter(
.subscribe({
Log.v("LOG", "it = $it ${it.data}")
if (it.data.count_checked != it.data.count_all.toInt()) {
showTech(uniq_id, dataTech, it)
}
else {
showTech(uniq_id, dataTech, it, dataShow)
} else {
viewState.toBack()
}
@ -70,7 +75,12 @@ class TestPresenter(
//router.openPhoneEnterScreen()
}
fun showTech(uniq_id: String, dataTech: DataTech, checkupShowList: CheckupShowList) {
fun showTech(
uniq_id: String,
dataTech: DataTech,
checkupShowList: CheckupShowList?,
dataShow: DataShow
) {
Log.v(
"LOG",
"showTech uniq_id = $uniq_id,"
@ -94,13 +104,18 @@ class TestPresenter(
it.data.data.forEach {
Log.v("LOG", "showTech forEach ${it}")
if ((it.value != "1") && (it.value != "0")) {
if ((it.value != "1") && (it.value != "0") && (it.id != dataShow.id)) {
newShowTech.add(it)
Log.v("LOG", "showTech openTestCheckupScreen ${newShowTech}")
}
}
if (newShowTech.isNotEmpty()) {
navRouter.openTestCheckupScreen(newShowTech.first(), uniq_id, dataTech, checkupShowList)
navRouter.openTestCheckupScreen(
newShowTech.first(),
uniq_id,
dataTech,
checkupShowList
)
} else {
viewState.toBack()
}
@ -121,4 +136,68 @@ class TestPresenter(
}
fun skipTech(
uniq_id: String,
dataTech: DataTech,
checkupShowList: CheckupShowList?,
dataShow: DataShow
) {
Log.v(
"LOG",
"skipTech uniq_id = $uniq_id,"
)
disposable += techInteractor
.showTech(uniq_id)
.ioToMain()
.doOnSubscribe {
Log.v("LOG", "it 2 = $it")
// viewState.showLoading()
}
.doAfterTerminate {
viewState.hideLoading()
}
.subscribe({ it ->
Log.v("LOG", "skipTech ${it.data.data}")
val newShowTech = mutableListOf<DataShow>()
for (i in 0 until it.data.data.size) {
if (it.data.data[i] == dataShow) {
if (i+1 != it.data.data.size) {
navRouter.openTestCheckupScreen(
it.data.data[i + 1],
uniq_id,
dataTech,
null
)
}
else {
navRouter.openTestCheckupScreen(
it.data.data[0],
uniq_id,
dataTech,
null
)
}
}
}
}, {
if (it is ApiException) {
if (it.code == RestApiCodes.NotFound.code) {
} else {
this.handleError(it)
}
} else {
this.handleError(it)
}
})
}
}

View File

@ -213,10 +213,12 @@
<TextView
android:id="@+id/tvStatusName"
style="@style/BlockValueTitleStyle"
style="@style/BlockValueStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Проверка 0 из 0"
android:layout_marginBottom="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvStatusInfoTitle" />

View File

@ -76,7 +76,6 @@
app:layout_constraintTop_toTopOf="@id/checkupsBody">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -90,6 +89,7 @@
android:focusable="true"
android:focusableInTouchMode="true"
android:text="Путевой лист:"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent" />
@ -171,6 +171,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Номер ПЛ"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="@+id/divider4" />
<TextView
@ -178,6 +179,7 @@
style="@style/BlockValueStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="@id/tvNumberPLTitle"
tools:text="23" />
@ -186,6 +188,7 @@
style="@style/BlockValueDividerStyle"
android:layout_width="match_parent"
android:layout_height="1dp"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="@id/tvNumberPL" />
<TextView
@ -194,6 +197,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Дата ПЛ"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="@+id/divider5" />
<TextView
@ -201,6 +205,7 @@
style="@style/BlockValueStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="@id/tvDatePLTitle"
tools:text="18.04.2024" />
@ -212,9 +217,6 @@
app:layout_constraintTop_toBottomOf="@id/tvDatePL" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
@ -224,11 +226,11 @@
android:id="@+id/startTest"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/btn_rounded_blue"
android:text="Начать проверки"
android:textColor="@color/white"
android:textSize="12sp"
android:background="@drawable/btn_rounded_blue"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cvMainInfoContainer" />
@ -237,11 +239,11 @@
android:id="@+id/signButton"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/btn_rounded_blue"
android:text="Допустить и подписать"
android:textColor="@color/white"
android:textSize="12sp"
android:background="@drawable/btn_rounded_blue"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/startTest" />
@ -251,19 +253,16 @@
android:id="@+id/notTest"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/btn_rounded_blue"
android:text="Не допустить и подписать"
android:textColor="@color/white"
android:textSize="12sp"
android:background="@drawable/btn_rounded_blue"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/signButton" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.card.MaterialCardView
@ -274,7 +273,6 @@
app:layout_constraintTop_toBottomOf="@id/checkupsBody">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -292,7 +290,7 @@
<TextView
android:id="@+id/tvStatusName"
style="@style/BlockValueTitleStyle"
style="@style/BlockValueStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="В работе"
@ -302,10 +300,12 @@
<TextView
android:id="@+id/tvStatusTest"
style="@style/BlockValueTitleStyle"
style="@style/BlockValueStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:text="Продено 2 проверки"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvStatusName" />
@ -316,7 +316,6 @@
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

View File

@ -7,6 +7,12 @@
android:orientation="vertical">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
@ -17,6 +23,7 @@
android:clipToPadding="false"
android:paddingTop="4dp"
tools:listitem="@layout/item_checkup" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</RelativeLayout>