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

This commit is contained in:
Azat Sagutdinov 2024-05-16 16:51:12 +03:00
parent cac9026c88
commit 67ad9f0f26
23 changed files with 523 additions and 15 deletions

View File

@ -258,6 +258,7 @@
<string name="sos">sos</string>
<string name="park_toolbar">Парк</string>
<string name="test_toolbar">Тест</string>

View File

@ -10,6 +10,7 @@ import retrofit2.http.*
import ru.tele2med.mobile.BuildConfig.*
import ru.tele2med.mobile.data.api.entity.request.BeginMedicalCheckupFinall
import ru.tele2med.mobile.data.api.entity.response.*
import ru.tele2med.mobile.domain.entity.CheckupData
interface ApiService {
@ -329,6 +330,20 @@ interface ApiService {
): Single<TechShowListResponse>
@Multipart
@POST("${API_BASE_URL}waybills/checklist/update/{uniq_id}")
fun update(
@Path("uniq_id") uuid: String,
@Part("uniq_id") uuidPart: RequestBody,
@Part("data") data: List<CheckupData>?,
@Header("token") token: String? = "iddqd",
@Header("Authorization") tokenUser: String?
): Single<CheckupShowListResponse>
}

View File

@ -0,0 +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 )

View File

@ -0,0 +1,23 @@
package ru.tele2med.mobile.data.db
import androidx.room.Entity
import androidx.room.PrimaryKey
import ru.tele2med.mobile.domain.entity.DataShow
@Entity(tableName = "tech_checkups")
data class TechCheckupsTests(
val id: String,
@PrimaryKey
val uniq_id: String,
val template_checklist_uniq_id: String,
val waybill_uniq_id: String?,
val techcontrol_uuid: String?,
val organization_id: String?,
val name: String?,
val comment: String?,
val date_create: String,
val date_update: String,
val date_delete: String,
val enabled: String,
val data: List<DataShow>
)

View File

@ -95,6 +95,14 @@ class DataConverter {
message = list.message
)
fun toCheckupShow(list: CheckupShowListResponse): CheckupShowList =
CheckupShowList(
af = list.af,
status = list.status,
data = list.data,
message = list.message
)
fun toTech(tech: TechResponse): Tech =
Tech(

View File

@ -108,5 +108,21 @@ class TechRepositoryImpl(
)
.map(dataConverter::toTechShow)
override fun updateCheckList(
id: String,
data: List<CheckupData>
): Single<CheckupShowList> =
apiService
.update(
uuid = id,
uuidPart = RequestBody.create(
MediaType.parse("text/plain"), id
),
tokenUser = "Bearer ${prefs.getTokenUser().toString()}",
data = data,
)
.map(dataConverter::toCheckupShow)
}

View File

@ -0,0 +1,9 @@
package ru.tele2med.mobile.domain.entity
data class CheckupData(
val uniq_id: String,
val label: String,
val value: String,
val view: String
)

View File

@ -0,0 +1,8 @@
package ru.tele2med.mobile.domain.entity
data class CheckupShowList(
val af: String,
val status: String,
val message: String,
val data: DataCheckupShow
)

View File

@ -0,0 +1,12 @@
package ru.tele2med.mobile.domain.entity
data class DataCheckupShow(
val id: String,
val uniq_id: String,
val template_checklist_fields_uniq_id: String,
val has_data: String?,
val value: String?,
val checklist_uuid: String?
)

View File

@ -28,4 +28,10 @@ class TechInteractor(
): Single<TechShowList> =
techRepository.showTech(id)
fun updateCheckList(
id: String,
data: List<CheckupData>
): Single<CheckupShowList> =
techRepository.showCheckup(id, data)
}

View File

@ -18,4 +18,8 @@ interface TechRepository {
id: String,
): Single<TechShowList>
fun updateCheckList(
id: String,
data: List<CheckupData>
): Single<CheckupShowList>
}

View File

@ -1,6 +1,7 @@
package ru.tele2med.mobile.presentation.router
import ru.tele2med.mobile.domain.entity.DataQR
import ru.tele2med.mobile.domain.entity.DataShow
import ru.tele2med.mobile.domain.entity.DataTech
import ru.terrakok.cicerone.Router
@ -123,6 +124,10 @@ class NavRouter : Router() {
navigateTo(NavScreens.getTechCheckup(dataTech))
}
fun openTestCheckupScreen(test: DataShow) {
navigateTo(NavScreens.getTestCheckup(test))
}
fun openMedicalCheckupsScreen() {
navigateTo(NavScreens.getMedicalCheckups())
}

View File

@ -1,6 +1,7 @@
package ru.tele2med.mobile.presentation.router
import ru.tele2med.mobile.domain.entity.DataQR
import ru.tele2med.mobile.domain.entity.DataShow
import ru.tele2med.mobile.domain.entity.DataTech
import ru.tele2med.mobile.presentation.ui.auth.login.LoginScreen
import ru.tele2med.mobile.presentation.ui.auth.number_enter.NumberEnterScreen
@ -40,6 +41,7 @@ import ru.tele2med.mobile.presentation.ui.menu.items.stats.StatsScreen
import ru.tele2med.mobile.presentation.ui.menu.items.status.StatusesScreen
import ru.tele2med.mobile.presentation.ui.menu.items.tech.TechScreen
import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.TechCheckupScreen
import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.test.TestScreen
import ru.tele2med.mobile.presentation.ui.menu.items.tonometr.TonScreen
object NavScreens {
@ -93,6 +95,8 @@ object NavScreens {
fun getTechCheckup(dataTech: DataTech): TechCheckupScreen = TechCheckupScreen(dataTech)
fun getTestCheckup(test: DataShow): TestScreen = TestScreen(test)
fun getTechCheckupInfo(dataTech: DataTech): TechCheckupScreen = TechCheckupScreen(dataTech)
fun getTechCheckupTests(dataTech: DataTech): TechCheckupScreen = TechCheckupScreen(dataTech)

View File

@ -52,8 +52,6 @@ class TechCheckupFragment : BaseMenuFragment(), TechCheckupView {
private fun initViewPager() {
context?.let {
MyViewPager.adapter = TechCheckupAdapter(
it, childFragmentManager, arguments?.getString(
DATA_QR

View File

@ -9,11 +9,13 @@ import android.view.View
import android.widget.MediaController
import androidx.annotation.RequiresApi
import androidx.core.net.toUri
import androidx.recyclerview.widget.LinearLayoutManager
import com.arellomobile.mvp.presenter.InjectPresenter
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
@ -22,8 +24,10 @@ import ru.tele2med.mobile.presentation.ui.menu.ReviewActivity
import ru.tele2med.mobile.presentation.ui.menu.base.BaseMenuFragment
import ru.tele2med.mobile.presentation.util.providePresenter
import kotlinx.android.synthetic.main.fragment_test_list.*
import kotlinx.android.synthetic.main.fragment_test_list.recyclerView
import kotlinx.android.synthetic.main.toolbar_with_help.*
import ru.tele2med.mobile.domain.entity.*
import ru.tele2med.mobile.presentation.ui.common.EndlessRecyclerViewScrollListener
class TechCheckupTestsFragment : BaseMenuFragment(), TechCheckupTestsView {
@ -34,6 +38,8 @@ class TechCheckupTestsFragment : BaseMenuFragment(), TechCheckupTestsView {
@InjectPresenter
lateinit var presenter: TechCheckupTestsPresenter
private lateinit var layoutManager: LinearLayoutManager
@ProvidePresenter
fun initPresenter(): TechCheckupTestsPresenter =
@ -44,8 +50,8 @@ class TechCheckupTestsFragment : BaseMenuFragment(), TechCheckupTestsView {
get() = R.layout.fragment_test_list
private val adapter: TestListAdapter by lazy {
TestListAdapter { idcheckup ->
presenter.get(idcheckup)
TestListAdapter { test ->
presenter.get(test)
}
}
@ -73,8 +79,19 @@ class TechCheckupTestsFragment : BaseMenuFragment(), TechCheckupTestsView {
}
}
}
layoutManager = LinearLayoutManager(context)
recyclerView.layoutManager = layoutManager
recyclerView.adapter = adapter
val scrollListener = object : EndlessRecyclerViewScrollListener(layoutManager) {
override fun onLoadMore() {
// presenter.getCheckups()
}
}
recyclerView.addOnScrollListener(scrollListener)
// tvDriverTitle.focusable
// tvDriverTitle.requestFocus()
var dataString = DATA_QR
@ -88,7 +105,7 @@ class TechCheckupTestsFragment : BaseMenuFragment(), TechCheckupTestsView {
}
override fun showCheckups(list: List<DataShow>) {
Log.v("SHOWCH", "data = $list")
Log.v("SHOWCH", "data tests = $list")
adapter.submitList(list)
}

View File

@ -9,14 +9,16 @@ import ru.tele2med.mobile.presentation.util.Prefs
import ru.tele2med.mobile.presentation.util.ioToMain
import io.reactivex.rxkotlin.plusAssign
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.interactor.TechInteractor
import ru.tele2med.mobile.presentation.router.NavRouter
@InjectViewState
class TechCheckupTestsPresenter(
private val techInteractor: TechInteractor,
private val prefs: Prefs,
private val stringId: String
private val navRouter: NavRouter
) : BasePresenter<TechCheckupTestsView>() {
fun onRefresh() {
@ -42,7 +44,7 @@ class TechCheckupTestsPresenter(
}
.subscribe({
Log.v("LOG", "it = $it ${it.message}")
Log.v("LOG", "it = $it ${it.data.data}")
viewState.showCheckups(it.data.data)
}, {
@ -57,8 +59,9 @@ class TechCheckupTestsPresenter(
})
}
fun get(code: String) {
println("qrcode4 $code")
fun get(test: DataShow) {
println("TechCheckupTestsPresenter ${test.uniq_id}")
navRouter.openTestCheckupScreen(test)
}

View File

@ -10,10 +10,11 @@ import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import ru.tele2med.mobile.R
import ru.tele2med.mobile.domain.entity.Data
import ru.tele2med.mobile.domain.entity.DataShow
class TestListAdapter(
val onItemClick: (checkupId: String) -> Unit
val onItemClick: (test: DataShow) -> Unit
) : ListAdapter<DataShow, TestListAdapter.ViewHolder>(
DIFF_CALLBACK
) {
@ -45,15 +46,16 @@ class TestListAdapter(
init {
view.setOnClickListener {
val list = getItem(adapterPosition)
onItemClick(list.uniq_id)
val test = getItem(adapterPosition)
onItemClick(test)
}
}
fun bind(list: DataShow) {
Log.v("BIND", "list = $list")
testName.text = list.name
testResult.text = list.value
testResult.text =
if (list.value == "1") "Исправно" else if (list.value == "0") "Неисправно" else "Ещё не пройдено"
}
}

View File

@ -0,0 +1,83 @@
package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.test
import android.os.Bundle
import android.util.Log
import android.view.View
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import com.google.gson.Gson
import kotlinx.android.synthetic.main.fragment_checkup_test.*
import ru.tele2med.mobile.R
import ru.tele2med.mobile.domain.entity.Data
import ru.tele2med.mobile.domain.entity.DataShow
import ru.tele2med.mobile.domain.entity.DataTech
import ru.tele2med.mobile.presentation.ui.base.BasePresenter
import ru.tele2med.mobile.presentation.ui.drawer.entity.ScreenType
import ru.tele2med.mobile.presentation.ui.menu.MenuActivity
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.tech.list.techCheckup.TechCheckupFragment
import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.info.TechCheckupInfoFragment
import ru.tele2med.mobile.presentation.util.providePresenter
class TestFragment : BaseMenuFragment(), TestView {
override val screenType: ScreenType
get() = ScreenType.WITHOUT_BORDER
@InjectPresenter
lateinit var presenter: TestPresenter
private var errorDialog: androidx.appcompat.app.AlertDialog? = null
@ProvidePresenter
fun initPresenter(): TestPresenter = providePresenter()
override fun getPresenter(): BasePresenter<*>? = presenter
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
(activity as MenuActivity).apply {
addDrawerToggle()
title = getString(R.string.test_toolbar)
}
val args = arguments
val data = args?.toString() // getString("data", "")
Log.v("TestFragment", "args = ${arguments?.getString("data")}")
val gson = Gson()
val dataTest = gson.fromJson(TEST, DataShow::class.java)
fillData(dataTest)
}
private fun fillData(data: DataShow) {
Log.v("TestFragment", "data = data.name = ${data.name}")
tvTestName.text = data.name
}
override val layoutId: Int
get() = R.layout.fragment_checkup_test
companion object {
private const val TEST = "TEST"
fun getInstance(test: DataShow): TestFragment {
val gson = Gson()
val string: String = gson.toJson(test)
return TestFragment().also {
it.arguments = Bundle().apply {
putString(TEST, string)
}
}
}
}
}

View File

@ -0,0 +1,26 @@
package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.test
import com.arellomobile.mvp.InjectViewState
import ru.tele2med.mobile.domain.entity.Position
import ru.tele2med.mobile.domain.interactor.SosInteractor
import ru.tele2med.mobile.presentation.Changes
import ru.tele2med.mobile.presentation.router.NavRouter
import ru.tele2med.mobile.presentation.ui.menu.base.BaseMenuPresenter
import ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.test.TestView
@InjectViewState
class TestPresenter(
private val sosInteractor: SosInteractor,
private val navRouter: NavRouter,
private val changes: Changes
) : BaseMenuPresenter<TestView>() {
private var position: Position? = null
override fun onFirstViewAttach() {
super.onFirstViewAttach()
}
}

View File

@ -0,0 +1,16 @@
package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.test
import androidx.fragment.app.Fragment
import ru.tele2med.mobile.domain.entity.DataShow
import ru.terrakok.cicerone.android.support.SupportAppScreen
class TestScreen(val test: DataShow) : SupportAppScreen() {
override fun getFragment(): Fragment {
return TestFragment.getInstance(test)
}
override fun getScreenKey(): String {
return TestFragment::class.java.name
}
}

View File

@ -0,0 +1,14 @@
package ru.tele2med.mobile.presentation.ui.menu.items.tech.list.techCheckup.tests.test
import com.arellomobile.mvp.viewstate.strategy.SkipStrategy
import com.arellomobile.mvp.viewstate.strategy.StateStrategyType
import ru.tele2med.mobile.domain.entity.DataShow
import ru.tele2med.mobile.presentation.ui.base.BaseView
interface TestView : BaseView {
fun bindTest(test: DataShow) {
}
}

View File

@ -0,0 +1,237 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/parent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/clMainContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingBottom="40dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/checkupsHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="24dp"
android:src="@drawable/ic_folder0_1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/carName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="20dp"
android:fontFamily="@font/roboto_regular"
android:text="Чеклист"
android:textColor="#515151"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@+id/imageView5"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteY="0dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/checkupsBody"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:background="@drawable/round"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkupsHeader">
<com.google.android.material.card.MaterialCardView
android:id="@+id/cvMainInfoContainer"
style="@style/BlockStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="@id/checkupsBody">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tvMainInfoTitle"
style="@style/BlockTitleStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="Проверка:"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvTestName"
style="@style/BlockValueStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/tvMainInfoTitle"
tools:text="Тормозная система" />
<View
android:id="@+id/divider"
style="@style/BlockValueDividerStyle"
android:layout_width="match_parent"
android:layout_height="1dp"
app:layout_constraintTop_toBottomOf="@id/tvTestName" />
<TextView
android:id="@+id/tvCommentName"
style="@style/BlockValueTitleStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Комментарий:"
app:layout_constraintTop_toBottomOf="@+id/divider" />
<TextView
android:id="@+id/tvComment"
style="@style/BlockValueStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvCommentName"
tools:text="Исправность тормозной системы (включая манометр пневатического когоыгфрвыфрвфрывгвыфвфв вфывф" />
<View
android:id="@+id/divider3"
style="@style/BlockValueDividerStyle"
android:layout_width="match_parent"
android:layout_height="1dp"
app:layout_constraintTop_toBottomOf="@id/tvComment" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<Button
android:id="@+id/trueBtn"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:background="@drawable/btn_rounded_blue"
android:text="Исправно"
android:textColor="@color/white"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cvMainInfoContainer" />
<Button
android:id="@+id/falseBtn"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:background="@drawable/btn_rounded_blue"
android:text="Неисправно"
android:textColor="@color/white"
android:textSize="12sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/trueBtn" />
<Button
android:id="@+id/skipBtn"
android:layout_width="120dp"
android:layout_marginTop="36dp"
android:layout_height="wrap_content"
android:background="@drawable/btn_rounded_blue"
android:text="Пропустить"
android:textColor="@color/white"
android:textSize="10sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/falseBtn" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.card.MaterialCardView
android:id="@+id/cvStatusInfoContainer"
style="@style/BlockStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/checkupsBody">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tvStatusInfoTitle"
style="@style/BlockTitleStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="Чеклист:"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvStatusName"
style="@style/BlockValueTitleStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Проверка 0 из 0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvStatusInfoTitle" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</RelativeLayout>

View File

@ -5,12 +5,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:background="@drawable/ic_notification_background"
android:background="@drawable/background_enter"
android:padding="18dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:background="@color/white"
android:background="@color/nav_drawer_background"
android:layout_height="match_parent">