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

This commit is contained in:
Azat Sagutdinov 2024-05-27 17:32:01 +03:00
parent 67ad9f0f26
commit 0392253128
17 changed files with 213 additions and 72 deletions

View File

@ -335,7 +335,7 @@ interface ApiService {
fun update( fun update(
@Path("uniq_id") uuid: String, @Path("uniq_id") uuid: String,
@Part("uniq_id") uuidPart: RequestBody, @Part("uniq_id") uuidPart: RequestBody,
@Part("data") data: List<CheckupData>?, @Part("data") data: RequestBody?,
@Header("token") token: String? = "iddqd", @Header("token") token: String? = "iddqd",
@Header("Authorization") tokenUser: String? @Header("Authorization") tokenUser: String?
): Single<CheckupShowListResponse> ): Single<CheckupShowListResponse>

View File

@ -1 +1 @@
package ru.tele2med.mobile.data.api.entity.response import ru.tele2med.mobile.domain.entity.* data class CheckupShowListResponse( val af: String, val status: String, val message: String, val data: DataCheckupShow ) package ru.tele2med.mobile.data.api.entity.response import ru.tele2med.mobile.domain.entity.* data class CheckupShowListResponse( val af: String, val status: String, val message: String, val data: List<DataCheckupShow> )

View File

@ -1,5 +1,6 @@
package ru.tele2med.mobile.data.repository package ru.tele2med.mobile.data.repository
import com.google.gson.Gson
import ru.tele2med.mobile.domain.repository.QRRepository import ru.tele2med.mobile.domain.repository.QRRepository
import ru.tele2med.mobile.presentation.util.Prefs import ru.tele2med.mobile.presentation.util.Prefs
import io.reactivex.Single import io.reactivex.Single
@ -109,20 +110,20 @@ class TechRepositoryImpl(
.map(dataConverter::toTechShow) .map(dataConverter::toTechShow)
override fun updateCheckList( override fun updateCheckList(
uniq_id: String,
id: String, id: String,
data: List<CheckupData> data: List<CheckupData>
): Single<CheckupShowList> = ): Single<CheckupShowList> =
apiService apiService
.update( .update(
uuid = id, uuid = uniq_id,
uuidPart = RequestBody.create( uuidPart = RequestBody.create(
MediaType.parse("text/plain"), id MediaType.parse("text/plain"), uniq_id
), ),
tokenUser = "Bearer ${prefs.getTokenUser().toString()}", tokenUser = "Bearer ${prefs.getTokenUser().toString()}",
data = data, data = RequestBody.create(MediaType.parse("text/plain"), Gson().toJson(data))
) )
.map(dataConverter::toCheckupShow) .map(dataConverter::toCheckupShow)
} }

View File

@ -52,6 +52,7 @@ import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.TechListPresenter
import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.TechCheckupPresenter import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.TechCheckupPresenter
import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.info.TechCheckupInfoPresenter import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.info.TechCheckupInfoPresenter
import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.TechCheckupTestsPresenter import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.TechCheckupTestsPresenter
import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.test.TestPresenter
import ru.tele2med.mobile.presentation.ui.menu.items.tech.park.ParkPresenter import ru.tele2med.mobile.presentation.ui.menu.items.tech.park.ParkPresenter
import ru.tele2med.mobile.presentation.ui.models.UiConverter import ru.tele2med.mobile.presentation.ui.models.UiConverter
import ru.tele2med.mobile.presentation.ui.splash.SplashPresenter import ru.tele2med.mobile.presentation.ui.splash.SplashPresenter
@ -72,13 +73,16 @@ fun presenterModule() = Kodein.Module(name = "presenterModule") {
} }
bind() from factory { stringId: String -> bind() from factory { stringId: String ->
TechCheckupTestsPresenter(instance(), instance(), stringId) TechCheckupTestsPresenter(instance(), instance(), instance())
} }
bind() from provider { bind() from provider {
ParkPresenter(instance(), instance(), instance()) ParkPresenter(instance(), instance(), instance())
} }
bind() from provider {
TestPresenter(instance(), instance())
}
bind() from provider { bind() from provider {
TechPresenter() TechPresenter()

View File

@ -4,5 +4,5 @@ data class CheckupShowList(
val af: String, val af: String,
val status: String, val status: String,
val message: String, val message: String,
val data: DataCheckupShow val data: List<DataCheckupShow>
) )

View File

@ -29,9 +29,11 @@ class TechInteractor(
techRepository.showTech(id) techRepository.showTech(id)
fun updateCheckList( fun updateCheckList(
uniq_id: String,
id: String, id: String,
data: List<CheckupData> data: List<CheckupData>
): Single<CheckupShowList> = ): Single<CheckupShowList> =
techRepository.showCheckup(id, data) techRepository.updateCheckList(uniq_id, id, data)
} }

View File

@ -19,6 +19,7 @@ interface TechRepository {
): Single<TechShowList> ): Single<TechShowList>
fun updateCheckList( fun updateCheckList(
uniq_id: String,
id: String, id: String,
data: List<CheckupData> data: List<CheckupData>
): Single<CheckupShowList> ): Single<CheckupShowList>

View File

@ -124,8 +124,8 @@ class NavRouter : Router() {
navigateTo(NavScreens.getTechCheckup(dataTech)) navigateTo(NavScreens.getTechCheckup(dataTech))
} }
fun openTestCheckupScreen(test: DataShow) { fun openTestCheckupScreen(test: DataShow, uniq_id: String, dataTech: DataTech) {
navigateTo(NavScreens.getTestCheckup(test)) navigateTo(NavScreens.getTestCheckup(test, uniq_id, dataTech))
} }
fun openMedicalCheckupsScreen() { fun openMedicalCheckupsScreen() {

View File

@ -95,7 +95,7 @@ object NavScreens {
fun getTechCheckup(dataTech: DataTech): TechCheckupScreen = TechCheckupScreen(dataTech) fun getTechCheckup(dataTech: DataTech): TechCheckupScreen = TechCheckupScreen(dataTech)
fun getTestCheckup(test: DataShow): TestScreen = TestScreen(test) fun getTestCheckup(test: DataShow, uniq_id: String, dataTech: DataTech): TestScreen = TestScreen(test, uniq_id, dataTech)
fun getTechCheckupInfo(dataTech: DataTech): TechCheckupScreen = TechCheckupScreen(dataTech) fun getTechCheckupInfo(dataTech: DataTech): TechCheckupScreen = TechCheckupScreen(dataTech)

View File

@ -76,6 +76,10 @@ class TechCheckupInfoFragment : BaseMenuFragment(), TechCheckupInfoView {
val gson = Gson() val gson = Gson()
val data = gson.fromJson(dataString, DataTech::class.java) val data = gson.fromJson(dataString, DataTech::class.java)
startTest.setOnClickListener {
presenter.updateTech(, data.uniq_id, data)
}
// tvDriverTitle.focusable // tvDriverTitle.focusable
// tvDriverTitle.requestFocus() // tvDriverTitle.requestFocus()
@ -110,15 +114,6 @@ class TechCheckupInfoFragment : BaseMenuFragment(), TechCheckupInfoView {
} }
startTest.setOnClickListener {
presenter.updateTech(
data.uniq_id,
data.vehicle_id,
data.date_,
data.time_,
data.result_id
)
}
} }

View File

@ -9,13 +9,15 @@ import ru.tele2med.mobile.presentation.util.Prefs
import ru.tele2med.mobile.presentation.util.ioToMain import ru.tele2med.mobile.presentation.util.ioToMain
import io.reactivex.rxkotlin.plusAssign import io.reactivex.rxkotlin.plusAssign
import ru.tele2med.mobile.data.api.entity.exception.ApiException import ru.tele2med.mobile.data.api.entity.exception.ApiException
import ru.tele2med.mobile.domain.entity.DataShow
import ru.tele2med.mobile.domain.entity.DataTech import ru.tele2med.mobile.domain.entity.DataTech
import ru.tele2med.mobile.domain.interactor.TechInteractor import ru.tele2med.mobile.domain.interactor.TechInteractor
import ru.tele2med.mobile.presentation.router.NavRouter
@InjectViewState @InjectViewState
class TechCheckupInfoPresenter( class TechCheckupInfoPresenter(
private val techInteractor: TechInteractor, private val techInteractor: TechInteractor,
private val prefs: Prefs, private val navRouter: NavRouter,
private val stringId: String private val stringId: String
) : BasePresenter<TechCheckupInfoView>() { ) : BasePresenter<TechCheckupInfoView>() {
@ -23,39 +25,12 @@ class TechCheckupInfoPresenter(
} }
fun updateTech(id: String, vehicleId: String, date: String, time: String, resultId: String) { fun updateTech(test: DataShow, uniq_id: String, dataTech: DataTech) {
Log.v( navRouter.openTestCheckupScreen(test, uniq_id, dataTech)
"LOG",
"it id = $id, vehicleId = $vehicleId date = $date, time = $time, resultId = $resultId"
)
disposable += techInteractor
.updateTech(id, vehicleId, date, time, resultId)
.ioToMain()
.doOnSubscribe {
Log.v("LOG", "it 2 = $it")
viewState.showLoading()
}
.doAfterTerminate {
viewState.hideLoading()
}
.subscribe({
Log.v("LOG", "it = $it ${it.message}")
}, {
if (it is ApiException) {
if (it.code == RestApiCodes.NotFound.code) {
} else {
this.handleError(it)
}
} else {
this.handleError(it)
}
})
} }
fun showCheckUp() { fun showCheckUp() {
val gson = Gson() val gson = Gson()
val data = gson.fromJson(stringId, DataTech::class.java) val data = gson.fromJson(stringId, DataTech::class.java)

View File

@ -51,7 +51,13 @@ class TechCheckupTestsFragment : BaseMenuFragment(), TechCheckupTestsView {
private val adapter: TestListAdapter by lazy { private val adapter: TestListAdapter by lazy {
TestListAdapter { test -> TestListAdapter { test ->
presenter.get(test) val gson = Gson()
presenter.get(
test,
gson.fromJson(DATA_QR, DataTech::class.java).uniq_id,
gson.fromJson(DATA_QR, DataTech::class.java)
)
} }
} }
@ -87,7 +93,7 @@ class TechCheckupTestsFragment : BaseMenuFragment(), TechCheckupTestsView {
val scrollListener = object : EndlessRecyclerViewScrollListener(layoutManager) { val scrollListener = object : EndlessRecyclerViewScrollListener(layoutManager) {
override fun onLoadMore() { override fun onLoadMore() {
// presenter.getCheckups() // presenter.getCheckups()
} }
} }
recyclerView.addOnScrollListener(scrollListener) recyclerView.addOnScrollListener(scrollListener)
@ -150,7 +156,10 @@ class TechCheckupTestsFragment : BaseMenuFragment(), TechCheckupTestsView {
putString(TechCheckupTestsFragment.DATA_QR, string) putString(TechCheckupTestsFragment.DATA_QR, string)
} }
Log.v("COMP", "data4 = ${it.requireArguments().getString(TechCheckupTestsFragment.DATA_QR)}") Log.v(
"COMP",
"data4 = ${it.requireArguments().getString(TechCheckupTestsFragment.DATA_QR)}"
)
} }
} }

View File

@ -59,9 +59,9 @@ class TechCheckupTestsPresenter(
}) })
} }
fun get(test: DataShow) { fun get(test: DataShow, uniq_id: String, dataTech: DataTech) {
println("TechCheckupTestsPresenter ${test.uniq_id}") println("TechCheckupTestsPresenter ${test.uniq_id}")
navRouter.openTestCheckupScreen(test) navRouter.openTestCheckupScreen(test, uniq_id, dataTech)
} }

View File

@ -1,6 +1,8 @@
package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.test package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.test
import android.os.Bundle import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Log import android.util.Log
import android.view.View import android.view.View
import com.arellomobile.mvp.presenter.InjectPresenter import com.arellomobile.mvp.presenter.InjectPresenter
@ -8,6 +10,7 @@ import com.arellomobile.mvp.presenter.ProvidePresenter
import com.google.gson.Gson import com.google.gson.Gson
import kotlinx.android.synthetic.main.fragment_checkup_test.* import kotlinx.android.synthetic.main.fragment_checkup_test.*
import ru.tele2med.mobile.R import ru.tele2med.mobile.R
import ru.tele2med.mobile.di.module.navigationModule
import ru.tele2med.mobile.domain.entity.Data import ru.tele2med.mobile.domain.entity.Data
import ru.tele2med.mobile.domain.entity.DataShow import ru.tele2med.mobile.domain.entity.DataShow
import ru.tele2med.mobile.domain.entity.DataTech import ru.tele2med.mobile.domain.entity.DataTech
@ -18,6 +21,7 @@ import ru.tele2med.mobile.presentation.ui.menu.base.BaseMenuFragment
import ru.tele2med.mobile.presentation.ui.menu.items.result.ResFragment import ru.tele2med.mobile.presentation.ui.menu.items.result.ResFragment
import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.TechCheckupFragment import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.TechCheckupFragment
import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.info.TechCheckupInfoFragment import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.info.TechCheckupInfoFragment
import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.TechCheckupTestsFragment
import ru.tele2med.mobile.presentation.util.providePresenter import ru.tele2med.mobile.presentation.util.providePresenter
class TestFragment : BaseMenuFragment(), TestView { class TestFragment : BaseMenuFragment(), TestView {
@ -43,36 +47,87 @@ class TestFragment : BaseMenuFragment(), TestView {
title = getString(R.string.test_toolbar) title = getString(R.string.test_toolbar)
} }
val args = arguments // val args = arguments
val data = args?.toString() // getString("data", "") // val data = args?.toString() // getString("data", "")
Log.v("TestFragment", "args = ${arguments?.getString("data")}") Log.v("TestFragment", "args = ${arguments?.getString(TEST)}")
val gson = Gson() val gson = Gson()
val dataTest = gson.fromJson(TEST, DataShow::class.java)
fillData(dataTest) var stringTech = arguments?.getString(TECH)
val dataTech = gson.fromJson(stringTech, DataTech::class.java)
if (arguments?.getString(TEST) == null) {
Handler(Looper.getMainLooper()).post {
presenter.toTech(dataTech)
// interact with ViewPager here
}
// toBack()
} else {
var dataString = arguments?.getString(TEST)
val data = gson.fromJson(dataString, DataShow::class.java)
var uniq_id = arguments?.getString(UNIQ_ID)
// val gson = Gson()
// val dataTest = gson.fromJson(TEST, DataShow::class.java)
fillData(data)
actions(data, uniq_id ?: "", dataTech)
}
} }
private fun fillData(data: DataShow) { private fun fillData(data: DataShow) {
Log.v("TestFragment", "data = data.name = ${data.name}") Log.v("TestFragment", "data = data.name = ${data.name}")
tvTestName.text = data.name tvTestName.text = data.name
tvComment.text = data.comment
tvStatusName.text = "Проверка ${data.order}"
} }
override fun toBack() {
activity?.onBackPressed()
}
private fun actions(data: DataShow, uniq_id: String, dataTech: DataTech) {
trueBtn.setOnClickListener {
presenter.setValue(uniq_id, data.uniq_id, data, "1", dataTech)
}
falseBtn.setOnClickListener {
presenter.setValue(uniq_id, data.uniq_id, data, "0", dataTech)
}
}
override val layoutId: Int override val layoutId: Int
get() = R.layout.fragment_checkup_test get() = R.layout.fragment_checkup_test
companion object { companion object {
private const val TEST = "TEST" private var TEST = "TEST"
private var UNIQ_ID = "UNIQ_ID"
private var TECH = "TECH"
fun getInstance(test: DataShow): TestFragment {
fun getInstance(test: DataShow, uniq_id: String, dataTech: DataTech): TestFragment {
val gson = Gson() val gson = Gson()
val string: String = gson.toJson(test) val string: String = gson.toJson(test)
this.TEST = string
val stringTech: String = gson.toJson(dataTech)
this.TECH = stringTech
return TestFragment().also { return TestFragment().also {
it.arguments = Bundle().apply { it.arguments = Bundle().apply {
putString(TEST, string) putString(TEST, string)
putString(UNIQ_ID, uniq_id)
putString(TECH, stringTech)
} }
} }

View File

@ -1,26 +1,120 @@
package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.test package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.test
import android.util.Log
import com.arellomobile.mvp.InjectViewState import com.arellomobile.mvp.InjectViewState
import io.reactivex.rxkotlin.plusAssign
import ru.tele2med.mobile.data.api.entity.exception.ApiException
import ru.tele2med.mobile.domain.entity.CheckupData
import ru.tele2med.mobile.domain.entity.DataShow
import ru.tele2med.mobile.domain.entity.DataTech
import ru.tele2med.mobile.domain.entity.Position import ru.tele2med.mobile.domain.entity.Position
import ru.tele2med.mobile.domain.interactor.SosInteractor import ru.tele2med.mobile.domain.interactor.TechInteractor
import ru.tele2med.mobile.presentation.Changes
import ru.tele2med.mobile.presentation.router.NavRouter import ru.tele2med.mobile.presentation.router.NavRouter
import ru.tele2med.mobile.presentation.ui.base.entity.RestApiCodes
import ru.tele2med.mobile.presentation.ui.menu.base.BaseMenuPresenter import ru.tele2med.mobile.presentation.ui.menu.base.BaseMenuPresenter
import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.test.TestView import ru.tele2med.mobile.presentation.util.ioToMain
@InjectViewState @InjectViewState
class TestPresenter( class TestPresenter(
private val sosInteractor: SosInteractor, private val techInteractor: TechInteractor,
private val navRouter: NavRouter, private val navRouter: NavRouter
private val changes: Changes
) : BaseMenuPresenter<TestView>() { ) : BaseMenuPresenter<TestView>() {
private var position: Position? = null private var position: Position? = null
override fun onFirstViewAttach() { override fun onFirstViewAttach() {
super.onFirstViewAttach() super.onFirstViewAttach()
}
fun toTech(dataTech: DataTech) {
navRouter.openTechCheckupScreen(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")
disposable += techInteractor
.updateCheckList(uniq_id, id, data)
.ioToMain()
.doOnSubscribe {
Log.v("LOG", "it 2 = $it")
viewState.showLoading()
}
.doAfterTerminate {
viewState.hideLoading()
// viewState.toBack()
}
.subscribe({
Log.v("LOG", "it = $it ${it.data}")
showTech(uniq_id, dataTech)
}, {
if (it is ApiException) {
if (it.code == RestApiCodes.NotFound.code) {
} else {
this.handleError(it)
}
} else {
this.handleError(it)
}
})
//router.openPhoneEnterScreen()
}
fun showTech(uniq_id: String, dataTech: DataTech) {
Log.v(
"LOG",
"showTech 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", "showTech ${it.data.data}")
val newShowTech = mutableListOf<DataShow>()
it.data.data.forEach {
Log.v("LOG", "showTech forEach ${it}")
if ((it.value != "1") && (it.value != "0")) {
newShowTech.add(it)
Log.v("LOG", "showTech openTestCheckupScreen ${newShowTech}")
}
}
if (newShowTech.isNotEmpty()) {
navRouter.openTestCheckupScreen(newShowTech.first(), uniq_id, dataTech)
} else {
viewState.toBack()
}
// viewState.showCheckups(it.data.data)
}, {
if (it is ApiException) {
if (it.code == RestApiCodes.NotFound.code) {
} else {
this.handleError(it)
}
} else {
this.handleError(it)
}
})
}
} }

View File

@ -2,12 +2,13 @@ package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.test
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import ru.tele2med.mobile.domain.entity.DataShow import ru.tele2med.mobile.domain.entity.DataShow
import ru.tele2med.mobile.domain.entity.DataTech
import ru.terrakok.cicerone.android.support.SupportAppScreen import ru.terrakok.cicerone.android.support.SupportAppScreen
class TestScreen(val test: DataShow) : SupportAppScreen() { class TestScreen(val test: DataShow, val uniq_id: String, val dataTech: DataTech) : SupportAppScreen() {
override fun getFragment(): Fragment { override fun getFragment(): Fragment {
return TestFragment.getInstance(test) return TestFragment.getInstance(test, uniq_id, dataTech)
} }
override fun getScreenKey(): String { override fun getScreenKey(): String {

View File

@ -1,5 +1,6 @@
package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.test package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.test
import com.arellomobile.mvp.viewstate.strategy.OneExecutionStateStrategy
import com.arellomobile.mvp.viewstate.strategy.SkipStrategy import com.arellomobile.mvp.viewstate.strategy.SkipStrategy
import com.arellomobile.mvp.viewstate.strategy.StateStrategyType import com.arellomobile.mvp.viewstate.strategy.StateStrategyType
import ru.tele2med.mobile.domain.entity.DataShow import ru.tele2med.mobile.domain.entity.DataShow
@ -8,7 +9,10 @@ import ru.tele2med.mobile.presentation.ui.base.BaseView
interface TestView : BaseView { interface TestView : BaseView {
fun bindTest(test: DataShow) { fun bindTest(test: DataShow) {
} }
@StateStrategyType(OneExecutionStateStrategy::class)
fun toBack()
} }