Browse Source

1.添加测评module

王鹏鹏 2 years ago
parent
commit
0c1c0fc8c7

+ 24 - 0
evaluation/src/main/java/com/yingyangfly/evaluation/adapter/OtherEvaluationHistoryAdapter.kt

@@ -0,0 +1,24 @@
+package com.yingyangfly.evaluation.adapter
+
+import android.annotation.SuppressLint
+import com.yingyangfly.baselib.adapter.BaseDataBindingAdapter
+import com.yingyangfly.evaluation.R
+import com.yingyangfly.evaluation.databinding.ItemOtherEvaluationHistoryBinding
+import com.yingyangfly.evaluation.entity.SelectAnswerRecord
+
+/**
+ * 测评历史adapter
+ */
+class OtherEvaluationHistoryAdapter(override val layoutId: Int = R.layout.item_other_evaluation_history) :
+    BaseDataBindingAdapter<SelectAnswerRecord, ItemOtherEvaluationHistoryBinding>() {
+
+    var onClickListener: ((bean: SelectAnswerRecord) -> Unit)? = null
+
+    @SuppressLint("SetTextI18n")
+    override fun onBindViewHolder(
+        binding: ItemOtherEvaluationHistoryBinding, item: SelectAnswerRecord, position: Int
+    ) {
+        binding.data = item
+
+    }
+}

+ 9 - 0
evaluation/src/main/java/com/yingyangfly/evaluation/entity/GetSelectAnswerRecordBean.kt

@@ -0,0 +1,9 @@
+package com.yingyangfly.evaluation.entity
+
+/**
+ * 查询问卷记录接口
+ */
+class GetSelectAnswerRecordBean {
+    var limit: String = ""
+    var page: Int = 0
+}

+ 39 - 0
evaluation/src/main/java/com/yingyangfly/evaluation/entity/SelectAnswerRecordBean.kt

@@ -0,0 +1,39 @@
+package com.yingyangfly.evaluation.entity
+
+/**
+ * 其他测评历史记录
+ */
+data class SelectAnswerRecordBean(
+    val countId: Any,
+    val current: Int,
+    val maxLimit: Any,
+    val optimizeCountSql: Boolean,
+    val orders: List<Any>,
+    val pages: Int,
+    val records: List<SelectAnswerRecord>,
+    val searchCount: Boolean,
+    val size: Int,
+    val total: Int
+)
+
+data class SelectAnswerRecord(
+    val appUserId: String,
+    val createBy: String,
+    val createTime: String,
+    val examinationId: String,
+    val examinationTitle: String,
+    val id: String,
+    val limit: Int,
+    val orgCode: String,
+    val orgName: String,
+    val page: Int,
+    val questionId: String,
+    val questionOptionId: String,
+    val questionOptionName: String,
+    val questionScore: Int,
+    val questionTitle: String,
+    val recordId: String,
+    val updateBy: String,
+    val updateTime: String,
+    val usedTime: String
+)

+ 78 - 5
evaluation/src/main/java/com/yingyangfly/evaluation/history/EvaluationHistoryActivity.kt

@@ -8,14 +8,17 @@ import android.view.View
 import com.alibaba.android.arouter.facade.annotation.Route
 import com.yingyangfly.baselib.ext.getEndAnimation
 import com.yingyangfly.baselib.ext.getScaleAnimation
+import com.yingyangfly.baselib.ext.show
 import com.yingyangfly.baselib.ext.toast
 import com.yingyangfly.baselib.mvvm.BaseMVVMActivity
 import com.yingyangfly.baselib.router.RouterUrlCommon
 import com.yingyangfly.baselib.utils.JumpUtil
 import com.yingyangfly.evaluation.R
 import com.yingyangfly.evaluation.adapter.EvaluationHistoryAdapter
+import com.yingyangfly.evaluation.adapter.OtherEvaluationHistoryAdapter
 import com.yingyangfly.evaluation.databinding.ActivityEvaluationHistoryBinding
 import com.yingyangfly.evaluation.entity.EvaluationHistoryBean
+import com.yingyangfly.evaluation.entity.SelectAnswerRecord
 
 
 /**
@@ -26,11 +29,29 @@ class EvaluationHistoryActivity :
     BaseMVVMActivity<ActivityEvaluationHistoryBinding, EvaluationHistoryViewModel>(),
     View.OnTouchListener {
 
+    /**
+     * 其他测评
+     */
+    private var page = 1
+    private val otherEvaluationHistoryAdapter by lazy { OtherEvaluationHistoryAdapter() }
+    private var selectAnswerRecord = mutableListOf<SelectAnswerRecord>()
+
+    /**
+     * MOCA/MMSE测评
+     */
     private var results = mutableListOf<EvaluationHistoryBean>()
     private val adapter by lazy { EvaluationHistoryAdapter() }
 
     override fun initViews() {
         binding {
+            swipeOtherResult.setEnableLoadMore(true)
+            swipeOtherResult.setEnableRefresh(true)
+            rvOtherResult.adapter = otherEvaluationHistoryAdapter
+            otherEvaluationHistoryAdapter.setData(selectAnswerRecord)
+            otherEvaluationHistoryAdapter.onClickListener = {
+
+            }
+
             rvResult.adapter = adapter
             adapter.setData(results)
             adapter.onClickListener = {
@@ -51,11 +72,21 @@ class EvaluationHistoryActivity :
             layoutHead.setOnTouchListener(this@EvaluationHistoryActivity)
             radioEvaluation.setOnCheckedChangeListener { group, checkedId ->
                 if (checkedId == R.id.radioProfessionalEvaluation) {
+                    showEvaluationsView(false)
                     getReviewTaskHistoryList()
                 } else if (checkedId == R.id.radioOtherEvaluation) {
-                    getOtherReviewTaskHistory()
+                    showEvaluationsView(true)
+                    getOtherReviewTaskHistory(true, true)
                 }
             }
+
+            swipeOtherResult.setOnRefreshListener {
+                getOtherReviewTaskHistory(true, false)
+            }
+
+            swipeOtherResult.setOnLoadMoreListener {
+                getOtherReviewTaskHistory(false, false)
+            }
         }
     }
 
@@ -68,16 +99,36 @@ class EvaluationHistoryActivity :
         getReviewTaskHistoryList()
     }
 
-    private fun getOtherReviewTaskHistory() {
-        Log.e("wpp", "获取其他测评历史记录")
-
+    /**
+     * 获取其他测评历史记录
+     */
+    private fun getOtherReviewTaskHistory(isRefresh: Boolean, isShowLoading: Boolean) {
+        if (isRefresh) {
+            page = 1
+            binding.swipeOtherResult.resetNoMoreData()
+        } else {
+            page++
+        }
+        viewModel.getSelectAnswerRecord(page, isShowLoading, fail = {
+            endRefresh()
+            it.toast()
+        }, success = {
+            endRefresh()
+            if (isRefresh) {
+                selectAnswerRecord.clear()
+            }
+            if (it != null && it.records.isNullOrEmpty().not()) {
+                selectAnswerRecord.addAll(it.records)
+            } else {
+                binding.swipeOtherResult.finishLoadMoreWithNoMoreData()
+            }
+        })
     }
 
     /**
      * 加载数据
      */
     private fun getReviewTaskHistoryList() {
-        Log.e("wpp", "获取专业测评历史记录")
         results.clear()
         viewModel.getReviewTaskHistoryList(fail = {
             it.toast()
@@ -118,4 +169,26 @@ class EvaluationHistoryActivity :
         }
         return true
     }
+
+    /**
+     * 页面展示逻辑
+     */
+    private fun showEvaluationsView(isOtherEvaluations: Boolean) {
+        binding {
+            tvTitleTag.show(isOtherEvaluations.not())
+            resultLayout.show(isOtherEvaluations.not())
+            tvOtherTitleTag.show(isOtherEvaluations)
+            otherResultLayout.show(isOtherEvaluations)
+        }
+    }
+
+    /**
+     * 结束刷新
+     */
+    private fun endRefresh() {
+        binding {
+            swipeOtherResult.finishRefresh()
+            swipeOtherResult.finishLoadMore()
+        }
+    }
 }

+ 23 - 0
evaluation/src/main/java/com/yingyangfly/evaluation/history/EvaluationHistoryViewModel.kt

@@ -5,6 +5,8 @@ import com.yingyangfly.baselib.mvvm.BaseViewModel
 import com.yingyangfly.baselib.net.XUtils
 import com.yingyangfly.baselib.utils.GsonUtil
 import com.yingyangfly.evaluation.entity.EvaluationHistoryBean
+import com.yingyangfly.evaluation.entity.GetSelectAnswerRecordBean
+import com.yingyangfly.evaluation.entity.SelectAnswerRecordBean
 import com.yingyangfly.evaluation.net.EVALUATION_API
 
 /**
@@ -28,4 +30,25 @@ class EvaluationHistoryViewModel : BaseViewModel() {
     }.runUI(
         success, fail
     )
+
+    /**
+     * 获取测评历史
+     */
+    fun getSelectAnswerRecord(
+        index: Int,
+        isShowLoading: Boolean,
+        fail: ((msg: String) -> Unit)? = null,
+        success: ((success: SelectAnswerRecordBean?) -> Unit)? = null,
+    ) = launchFlow(isShowLoading) {
+        val requestBean = GetSelectAnswerRecordBean().apply {
+            page = index
+            limit = "10"
+        }
+        val body = XUtils.createJson(GsonUtil.GsonString(requestBean))
+        EVALUATION_API.getSelectAnswerRecord(body)
+    }.runUI(
+        success, fail
+    )
+
+
 }

+ 7 - 0
evaluation/src/main/java/com/yingyangfly/evaluation/net/EvaluationApiService.kt

@@ -71,4 +71,11 @@ interface EvaluationApiService {
      */
     @POST("questionRecord/saveAnswerRecord")
     suspend fun saveAnswerRecord(@Body requestBody: RequestBody): BaseResp<Any>
+
+    /**
+     * 查询问卷记录接口
+     */
+    @POST("questionRecord/selectAnswerRecord")
+    suspend fun getSelectAnswerRecord(@Body requestBody: RequestBody): BaseResp<SelectAnswerRecordBean>
+
 }

+ 14 - 0
evaluation/src/main/java/com/yingyangfly/evaluation/otherevaluation/OtherEvaluationActivity.kt

@@ -127,13 +127,17 @@ class OtherEvaluationActivity :
             page++
         }
         viewModel.getExaminationList(showLoading, page, evaluationType, fail = {
+            endRefresh()
             it.toast()
         }, success = {
+            endRefresh()
             if (isRefresh) {
                 evaluationList.clear()
             }
             if (it != null && it.records.isNullOrEmpty().not()) {
                 evaluationList.addAll(it.records)
+            } else {
+                binding.swipeEvaluation.finishLoadMoreWithNoMoreData()
             }
             examinationAdapter.setData(evaluationList)
         })
@@ -194,4 +198,14 @@ class OtherEvaluationActivity :
             }
         })
     }
+
+    /**
+     * 结束刷新
+     */
+    private fun endRefresh() {
+        binding {
+            swipeEvaluation.finishRefresh()
+            swipeEvaluation.finishLoadMore()
+        }
+    }
 }

+ 92 - 0
evaluation/src/main/res/layout/activity_evaluation_history.xml

@@ -225,11 +225,13 @@
                 </LinearLayout>
 
                 <LinearLayout
+                    android:id="@+id/resultLayout"
                     android:layout_width="match_parent"
                     android:layout_height="0dp"
                     android:layout_marginStart="@dimen/divider_34px"
                     android:layout_marginEnd="@dimen/divider_37px"
                     android:layout_marginBottom="@dimen/divider_36px"
+                    android:orientation="vertical"
                     app:layout_constraintBottom_toBottomOf="parent"
                     app:layout_constraintEnd_toEndOf="parent"
                     app:layout_constraintStart_toStartOf="parent"
@@ -242,6 +244,96 @@
                         app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
                 </LinearLayout>
 
+                <LinearLayout
+                    android:id="@+id/tvOtherTitleTag"
+                    android:layout_width="match_parent"
+                    android:layout_height="@dimen/divider_71px"
+                    android:layout_marginStart="@dimen/divider_34px"
+                    android:layout_marginTop="@dimen/divider_23px"
+                    android:layout_marginEnd="@dimen/divider_37px"
+                    android:background="@drawable/bg_evaluation_top_results"
+                    android:orientation="horizontal"
+                    app:layout_constraintEnd_toEndOf="parent"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toBottomOf="@+id/tvName">
+
+                    <androidx.appcompat.widget.AppCompatTextView
+                        android:layout_width="0dp"
+                        android:layout_height="match_parent"
+                        android:layout_weight="1.8"
+                        android:gravity="center"
+                        android:text="@string/evaluation_title"
+                        android:textColor="@android:color/white"
+                        android:textSize="@dimen/divider_24px"
+                        android:textStyle="bold" />
+
+                    <androidx.appcompat.widget.AppCompatTextView
+                        android:layout_width="0dp"
+                        android:layout_height="match_parent"
+                        android:layout_weight="1"
+                        android:gravity="center"
+                        android:text="@string/score"
+                        android:textColor="@android:color/white"
+                        android:textSize="@dimen/divider_24px"
+                        android:textStyle="bold" />
+
+                    <androidx.appcompat.widget.AppCompatTextView
+                        android:layout_width="0dp"
+                        android:layout_height="match_parent"
+                        android:layout_weight="2"
+                        android:gravity="center"
+                        android:text="@string/assessment_date"
+                        android:textColor="@android:color/white"
+                        android:textSize="@dimen/divider_24px"
+                        android:textStyle="bold" />
+
+                    <androidx.appcompat.widget.AppCompatTextView
+                        android:layout_width="0dp"
+                        android:layout_height="match_parent"
+                        android:layout_weight="1"
+                        android:gravity="center"
+                        android:text="@string/evaluation_time"
+                        android:textColor="@android:color/white"
+                        android:textSize="@dimen/divider_24px"
+                        android:textStyle="bold" />
+
+                    <androidx.appcompat.widget.AppCompatTextView
+                        android:layout_width="0dp"
+                        android:layout_height="match_parent"
+                        android:layout_weight="1"
+                        android:gravity="center"
+                        android:textColor="@android:color/white"
+                        android:textSize="@dimen/divider_24px"
+                        android:textStyle="bold" />
+
+                </LinearLayout>
+
+                <LinearLayout
+                    android:id="@+id/otherResultLayout"
+                    android:layout_width="match_parent"
+                    android:layout_height="0dp"
+                    android:layout_marginStart="@dimen/divider_34px"
+                    android:layout_marginEnd="@dimen/divider_37px"
+                    android:layout_marginBottom="@dimen/divider_36px"
+                    android:orientation="vertical"
+                    app:layout_constraintBottom_toBottomOf="parent"
+                    app:layout_constraintEnd_toEndOf="parent"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toBottomOf="@+id/tvOtherTitleTag">
+
+                    <com.scwang.smartrefresh.layout.SmartRefreshLayout
+                        android:id="@+id/swipeOtherResult"
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent">
+
+                        <androidx.recyclerview.widget.RecyclerView
+                            android:id="@+id/rvOtherResult"
+                            android:layout_width="match_parent"
+                            android:layout_height="match_parent"
+                            app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
+
+                    </com.scwang.smartrefresh.layout.SmartRefreshLayout>
+                </LinearLayout>
             </androidx.constraintlayout.widget.ConstraintLayout>
         </com.google.android.material.card.MaterialCardView>
     </androidx.constraintlayout.widget.ConstraintLayout>

+ 73 - 0
evaluation/src/main/res/layout/item_other_evaluation_history.xml

@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    tools:ignore="ResourceName">
+
+    <data>
+
+        <variable
+            name="data"
+            type="com.yingyangfly.evaluation.entity.SelectAnswerRecord" />
+    </data>
+
+    <LinearLayout
+        android:id="@+id/evaluationLayout"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/divider_98px"
+        android:orientation="horizontal">
+
+        <androidx.appcompat.widget.AppCompatTextView
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1.8"
+            android:gravity="center"
+            android:text="@{data.examinationTitle}"
+            android:textColor="@color/color_FF4A76FF"
+            android:textSize="@dimen/divider_24px"
+            android:textStyle="bold" />
+
+        <androidx.appcompat.widget.AppCompatTextView
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:text="@{data.recordId}"
+            android:textColor="@color/color_FF4A76FF"
+            android:textSize="@dimen/divider_24px"
+            android:textStyle="bold" />
+
+        <androidx.appcompat.widget.AppCompatTextView
+            android:id="@+id/tvReviewScore"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:text="@{data.createTime}"
+            android:textColor="@color/color_FF4A76FF"
+            android:textSize="@dimen/divider_24px"
+            android:textStyle="bold" />
+
+        <androidx.appcompat.widget.AppCompatTextView
+            android:id="@+id/tvReferenceValue"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:text="@{data.usedTime}"
+            android:textColor="@color/color_FF4A76FF"
+            android:textSize="@dimen/divider_24px"
+            android:textStyle="bold" />
+
+        <androidx.appcompat.widget.AppCompatTextView
+            android:id="@+id/tvDetails"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:text="@string/report_details"
+            android:textColor="@color/color_FF333333"
+            android:textSize="@dimen/divider_24px"
+            android:textStyle="bold" />
+
+    </LinearLayout>
+</layout>

+ 3 - 0
evaluation/src/main/res/values/strings.xml

@@ -71,4 +71,7 @@
     <string name="evaluation" tools:ignore="ResourceName">测评</string>
     <string name="continues" tools:ignore="ResourceName">继续</string>
     <string name="previous_question" tools:ignore="ResourceName">上一题</string>
+    <string name="evaluation_title" tools:ignore="ResourceName">测评标题</string>
+    <string name="evaluation_id" tools:ignore="ResourceName">试题ID</string>
+    <string name="evaluation_time" tools:ignore="ResourceName">用时</string>
 </resources>