Переглянути джерело

1.添加测评结果接口

王鹏鹏 2 роки тому
батько
коміт
91c7ba1567

+ 2 - 0
.idea/misc.xml

@@ -122,9 +122,11 @@
         <entry key="..\:/workspace/hcp-pad/home/src/main/res/drawable/shape_progress_bar.xml" value="0.219" />
         <entry key="..\:/workspace/hcp-pad/home/src/main/res/drawable/shape_ract_gold.xml" value="0.2185" />
         <entry key="..\:/workspace/hcp-pad/home/src/main/res/layout/activity_evaluation.xml" value="0.22239583333333332" />
+        <entry key="..\:/workspace/hcp-pad/home/src/main/res/layout/activity_evaluation_history.xml" value="0.22239583333333332" />
         <entry key="..\:/workspace/hcp-pad/home/src/main/res/layout/activity_evaluation_result.xml" value="0.23697916666666666" />
         <entry key="..\:/workspace/hcp-pad/home/src/main/res/layout/activity_home.xml" value="0.2" />
         <entry key="..\:/workspace/hcp-pad/home/src/main/res/layout/fragment_down_load_app.xml" value="0.21064814814814814" />
+        <entry key="..\:/workspace/hcp-pad/home/src/main/res/layout/item_evaluation_history.xml" value="0.23697916666666666" />
         <entry key="..\:/workspace/hcp-pad/home/src/main/res/layout/item_evaluation_result.xml" value="0.23697916666666666" />
         <entry key="..\:/workspace/hcp-pad/home/src/main/res/layout/item_game.xml" value="0.16" />
         <entry key="..\:/workspace/hcp-pad/home/src/main/res/layout/itewm_evaluation_result.xml" value="0.6" />

+ 5 - 0
baselib/src/main/java/com/yingyangfly/baselib/router/RouterUrlCommon.kt

@@ -170,4 +170,9 @@ object RouterUrlCommon {
      */
     const val paid = "/paid/paid"
 
+    /**
+     * 测评历史
+     */
+    const val evaluationHistory = "/evaluation/history"
+
 }

+ 8 - 0
home/src/main/AndroidManifest.xml

@@ -32,6 +32,14 @@
             android:screenOrientation="landscape"
             android:windowSoftInputMode="adjustResize|adjustPan" />
 
+        <activity
+            android:name="com.yingyangfly.home.evaluation.EvaluationHistoryActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:launchMode="singleTask"
+            android:screenOrientation="landscape"
+            android:windowSoftInputMode="adjustResize|adjustPan" />
+
+
         <service
             android:name="com.yingyangfly.home.updater.service.DownloadService"
             android:exported="false" />

+ 26 - 0
home/src/main/java/com/yingyangfly/home/adapter/EvaluationHistoryAdapter.kt

@@ -0,0 +1,26 @@
+package com.yingyangfly.home.adapter
+
+import android.text.TextUtils
+import com.yingyang.home.R
+import com.yingyang.home.databinding.ItemEvaluationHistoryBinding
+import com.yingyangfly.baselib.adapter.BaseDataBindingAdapter
+import com.yingyangfly.home.entity.Records
+
+/**
+ * 测评结果adapter
+ */
+class EvaluationHistoryAdapter(override val layoutId: Int = R.layout.item_evaluation_history) :
+    BaseDataBindingAdapter<Records, ItemEvaluationHistoryBinding>() {
+    override fun onBindViewHolder(
+        binding: ItemEvaluationHistoryBinding,
+        item: Records,
+        position: Int
+    ) {
+        binding.data = item
+        binding.tvStatus.text = if (TextUtils.equals("0", item.status)) {
+            "未评测"
+        } else {
+            "已评测"
+        }
+    }
+}

+ 12 - 12
home/src/main/java/com/yingyangfly/home/entity/ReviewTaskListBean.kt

@@ -1,11 +1,11 @@
 package com.yingyangfly.home.entity
 
 data class ReviewTaskListBean(
-    val countId: Any,
-    val current: Int,
-    val maxLimit: Any,
+    val countId: String,
+    val current: String,
+    val maxLimit: String,
     val optimizeCountSql: Boolean,
-    val orders: List<Any>,
+    val orders: List<String>,
     val pages: Int,
     val records: List<Records>,
     val searchCount: Boolean,
@@ -14,19 +14,19 @@ data class ReviewTaskListBean(
 )
 
 data class Records(
-    val createBy: Any,
-    val createTime: Any,
+    val createBy: String,
+    val createTime: String,
     val id: String,
-    val limit: Int,
-    val orgCode: Any,
+    val limit: String,
+    val orgCode: String,
     val orgName: String,
-    val page: Int,
-    val reviewId: Any,
+    val page: String,
+    val reviewId: String,
     val reviewTaskId: String,
     val reviewTaskName: String,
     val status: String,
     val type: String,
-    val updateBy: Any,
-    val updateTime: Any,
+    val updateBy: String,
+    val updateTime: String,
     val userId: String
 )

+ 1 - 1
home/src/main/java/com/yingyangfly/home/evaluation/EvaluationActivity.kt

@@ -89,7 +89,7 @@ class EvaluationActivity : BaseMVVMActivity<ActivityEvaluationBinding, Evaluatio
                         finish()
                     }
                     R.id.tvEvaluationHistory -> {
-                        JumpUtil.jumpActivity(RouterUrlCommon.evaluationResult, mContext)
+                        JumpUtil.jumpActivity(RouterUrlCommon.evaluationHistory, mContext)
                     }
                 }
             }

+ 137 - 0
home/src/main/java/com/yingyangfly/home/evaluation/EvaluationHistoryActivity.kt

@@ -0,0 +1,137 @@
+package com.yingyangfly.home.evaluation
+
+import android.annotation.SuppressLint
+import android.view.MotionEvent
+import android.view.View
+import com.alibaba.android.arouter.facade.annotation.Route
+import com.yingyang.home.R
+import com.yingyang.home.databinding.ActivityEvaluationHistoryBinding
+import com.yingyangfly.baselib.ext.getEndAnimation
+import com.yingyangfly.baselib.ext.getScaleAnimation
+import com.yingyangfly.baselib.ext.toast
+import com.yingyangfly.baselib.mvvm.BaseMVVMActivity
+import com.yingyangfly.baselib.router.RouterUrlCommon
+import com.yingyangfly.home.adapter.EvaluationHistoryAdapter
+import com.yingyangfly.home.entity.Records
+
+/**
+ * 历史记录测评
+ */
+@Route(path = RouterUrlCommon.evaluationHistory)
+class EvaluationHistoryActivity :
+    BaseMVVMActivity<ActivityEvaluationHistoryBinding, EvaluationHistoryViewModel>(),
+    View.OnTouchListener {
+
+    private var page = 1
+    private var results = mutableListOf<Records>()
+    private val adapter by lazy { EvaluationHistoryAdapter() }
+
+    override fun initViews() {
+        binding {
+            rvResult.adapter = adapter
+            adapter.setData(results)
+        }
+    }
+
+    @SuppressLint("ClickableViewAccessibility")
+    override fun initListener() {
+        binding {
+            layoutHead.setOnTouchListener(this@EvaluationHistoryActivity)
+            historySwipe.setEnableLoadMore(true)
+            historySwipe.setEnableRefresh(true)
+            historySwipe.setOnRefreshListener {
+                loadData(true, false)
+            }
+            historySwipe.setOnLoadMoreListener {
+                loadData(false, false)
+            }
+        }
+    }
+
+    override fun initData() {
+        getUserInfo()
+    }
+
+    override fun onResume() {
+        super.onResume()
+        loadData(true, true)
+    }
+
+    /**
+     * 加载数据
+     */
+    private fun loadData(isRefresh: Boolean, isLoading: Boolean) {
+        if (isRefresh) {
+            page = 1
+            binding.historySwipe.resetNoMoreData()
+        } else {
+            page++
+        }
+        viewModel.getReviewTaskList(page, isLoading, fail = {
+            endRefresh()
+            it.toast()
+        }, success = {
+            endRefresh()
+            if (isRefresh) {
+                results.clear()
+            }
+            it?.let {
+                if (page >= it.pages) {
+                    binding.historySwipe.finishLoadMoreWithNoMoreData()
+                }
+                if (it.records.isNullOrEmpty().not()) {
+                    results.addAll(it.records)
+                }
+            }
+            adapter.setData(results)
+        })
+    }
+
+    @SuppressLint("ClickableViewAccessibility")
+    override fun onTouch(v: View, event: MotionEvent): Boolean {
+        when (event.action) {
+            MotionEvent.ACTION_DOWN -> {
+                if (v.id == R.id.layoutHead) {
+                    v.startAnimation(getScaleAnimation())
+                }
+            }
+            MotionEvent.ACTION_UP -> {
+                v.startAnimation(getEndAnimation())
+                when (v.id) {
+                    R.id.layoutHead -> {
+                        finish()
+                    }
+                }
+            }
+            MotionEvent.ACTION_CANCEL -> {
+                if (v.id == R.id.layoutHead) {
+                    v.startAnimation(getEndAnimation())
+                }
+            }
+        }
+        return true
+    }
+
+    /**
+     * 获取个人中心信息接口
+     */
+    private fun getUserInfo() {
+        viewModel.getUserInfo(fail = {
+            it.toast()
+        }, success = {
+            if (it != null) {
+                binding.data = it
+            }
+        })
+    }
+
+    /**
+     * 结束刷新
+     */
+    private fun endRefresh() {
+        binding {
+            historySwipe.finishRefresh()
+            historySwipe.finishLoadMore()
+        }
+    }
+}

+ 48 - 0
home/src/main/java/com/yingyangfly/home/evaluation/EvaluationHistoryViewModel.kt

@@ -0,0 +1,48 @@
+package com.yingyangfly.home.evaluation
+
+import com.yingyangfly.baselib.bean.UserInfoBean
+import com.yingyangfly.baselib.mvvm.BaseViewModel
+import com.yingyangfly.baselib.net.XUtils
+import com.yingyangfly.baselib.utils.GsonUtil
+import com.yingyangfly.home.entity.PagingBean
+import com.yingyangfly.home.entity.ReviewTaskListBean
+import com.yingyangfly.home.net.HOME_API
+
+/**
+ * @author 王鹏鹏
+ * @description 工作台页面ViewModel
+ */
+class EvaluationHistoryViewModel : BaseViewModel() {
+
+    /**
+     * 获取测评历史
+     */
+    fun getReviewTaskList(
+        index: Int,
+        isLoading: Boolean,
+        fail: ((msg: String) -> Unit)? = null,
+        success: ((success: ReviewTaskListBean?) -> Unit)? = null,
+    ) = launchFlow(isLoading) {
+        val requestBean = PagingBean().apply {
+            page = index
+        }
+        val body = XUtils.createJson(GsonUtil.GsonString(requestBean))
+        HOME_API.getReviewTaskList(body)
+    }.runUI(
+        success,
+        fail
+    )
+
+    /**
+     * 获取个人中心信息接口
+     */
+    fun getUserInfo(
+        fail: ((msg: String) -> Unit)? = null,
+        success: ((success: UserInfoBean?) -> Unit)? = null,
+    ) = launchFlow(true) {
+        HOME_API.getUserInfo()
+    }.runUI(
+        success,
+        fail
+    )
+}

+ 7 - 0
home/src/main/manifest/AndroidManifest.xml

@@ -32,6 +32,13 @@
             android:screenOrientation="landscape"
             android:windowSoftInputMode="adjustResize|adjustPan" />
 
+        <activity
+            android:name="com.yingyangfly.home.evaluation.EvaluationHistoryActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:launchMode="singleTask"
+            android:screenOrientation="landscape"
+            android:windowSoftInputMode="adjustResize|adjustPan" />
+
         <service android:name="com.yingyangfly.home.updater.service.DownloadService"
             android:exported="false"/>
 

+ 219 - 0
home/src/main/res/layout/activity_evaluation_history.xml

@@ -0,0 +1,219 @@
+<?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:tools="http://schemas.android.com/tools"
+    tools:ignore="ResourceName">
+
+    <data>
+
+        <variable
+            name="data"
+            type="com.yingyangfly.baselib.bean.UserInfoBean" />
+    </data>
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        style="@style/layout_properties_specify_width_geight"
+        android:background="@mipmap/icon_uniform_background">
+
+        <LinearLayout
+            android:id="@+id/layoutHead"
+            style="@style/back_layout"
+            tools:ignore="MissingConstraints">
+
+            <androidx.appcompat.widget.AppCompatImageView style="@style/back_image" />
+
+            <androidx.appcompat.widget.AppCompatTextView style="@style/back_text" />
+        </LinearLayout>
+
+        <androidx.appcompat.widget.AppCompatTextView
+            android:id="@+id/tvTitle"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/divider_32px"
+            android:text="@string/evaluation_history_info"
+            android:textColor="@android:color/white"
+            android:textSize="@dimen/divider_34px"
+            android:textStyle="bold"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <com.google.android.material.card.MaterialCardView
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_marginStart="@dimen/divider_22px"
+            android:layout_marginTop="@dimen/divider_29px"
+            android:layout_marginEnd="@dimen/divider_22px"
+            android:layout_marginBottom="@dimen/divider_18px"
+            android:theme="@style/Theme.MaterialComponents.NoActionBar"
+            app:cardBackgroundColor="@android:color/white"
+            app:cardCornerRadius="@dimen/divider_28px"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tvTitle">
+
+            <androidx.constraintlayout.widget.ConstraintLayout
+                android:layout_width="match_parent"
+                android:layout_height="match_parent">
+
+                <androidx.appcompat.widget.AppCompatTextView
+                    android:id="@+id/tvName"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_marginStart="@dimen/divider_38px"
+                    android:layout_marginTop="@dimen/divider_33px"
+                    android:text='@{"姓名:"+data.username}'
+                    android:textColor="@color/color_FF333333"
+                    android:textSize="@dimen/divider_24px"
+                    android:textStyle="bold"
+                    app:layout_constraintEnd_toStartOf="@+id/tvSex"
+                    app:layout_constraintHorizontal_chainStyle="spread"
+                    app:layout_constraintHorizontal_weight="1"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toTopOf="parent" />
+
+                <androidx.appcompat.widget.AppCompatTextView
+                    android:id="@+id/tvSex"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="@dimen/divider_33px"
+                    android:text='@{"性别:"+data.username}'
+                    android:textColor="@color/color_FF333333"
+                    android:textSize="@dimen/divider_24px"
+                    android:textStyle="bold"
+                    app:layout_constraintEnd_toStartOf="@+id/tvAge"
+                    app:layout_constraintHorizontal_chainStyle="spread"
+                    app:layout_constraintHorizontal_weight="1"
+                    app:layout_constraintStart_toEndOf="@+id/tvName"
+                    app:layout_constraintTop_toTopOf="parent" />
+
+                <androidx.appcompat.widget.AppCompatTextView
+                    android:id="@+id/tvAge"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="@dimen/divider_33px"
+                    android:text="@string/patient_age"
+                    android:textColor="@color/color_FF333333"
+                    android:textSize="@dimen/divider_24px"
+                    android:textStyle="bold"
+                    app:layout_constraintEnd_toStartOf="@+id/tvEducationAge"
+                    app:layout_constraintHorizontal_chainStyle="spread"
+                    app:layout_constraintHorizontal_weight="1"
+                    app:layout_constraintStart_toEndOf="@+id/tvSex"
+                    app:layout_constraintTop_toTopOf="parent" />
+
+                <androidx.appcompat.widget.AppCompatTextView
+                    android:id="@+id/tvEducationAge"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="@dimen/divider_33px"
+                    android:text="@string/education_age"
+                    android:textColor="@color/color_FF333333"
+                    android:textSize="@dimen/divider_24px"
+                    android:textStyle="bold"
+                    app:layout_constraintEnd_toStartOf="@+id/tvNumber"
+                    app:layout_constraintHorizontal_chainStyle="spread"
+                    app:layout_constraintHorizontal_weight="1"
+                    app:layout_constraintStart_toEndOf="@+id/tvSex"
+                    app:layout_constraintTop_toTopOf="parent" />
+
+                <androidx.appcompat.widget.AppCompatTextView
+                    android:id="@+id/tvNumber"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="@dimen/divider_33px"
+                    android:text="@string/patient_id"
+                    android:textColor="@color/color_FF333333"
+                    android:textSize="@dimen/divider_24px"
+                    android:textStyle="bold"
+                    app:layout_constraintEnd_toEndOf="parent"
+                    app:layout_constraintHorizontal_chainStyle="spread"
+                    app:layout_constraintHorizontal_weight="1"
+                    app:layout_constraintStart_toEndOf="@+id/tvEducationAge"
+                    app:layout_constraintTop_toTopOf="parent" />
+
+                <LinearLayout
+                    android:id="@+id/tvTitleTag"
+                    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_top_results"
+                    android:orientation="horizontal"
+                    app:layout_constraintEnd_toEndOf="parent"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toBottomOf="@+id/tvNumber">
+
+                    <androidx.appcompat.widget.AppCompatTextView
+                        android:layout_width="0dp"
+                        android:layout_height="match_parent"
+                        android:layout_weight="1"
+                        android:gravity="center"
+                        android:text="@string/task_name"
+                        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/assessment_type"
+                        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/whether_evaluate"
+                        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: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:background="@drawable/bg_results_content"
+                    app:layout_constraintBottom_toBottomOf="parent"
+                    app:layout_constraintEnd_toEndOf="parent"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toBottomOf="@+id/tvTitleTag">
+
+                    <com.scwang.smartrefresh.layout.SmartRefreshLayout
+                        android:id="@+id/historySwipe"
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent">
+
+                        <androidx.recyclerview.widget.RecyclerView
+                            android:id="@+id/rvResult"
+                            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>
+
+</layout>

+ 60 - 0
home/src/main/res/layout/item_evaluation_history.xml

@@ -0,0 +1,60 @@
+<?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.home.entity.Records" />
+    </data>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/divider_98px"
+        android:background="@drawable/bg_evaluation_result"
+        android:orientation="horizontal">
+
+        <androidx.appcompat.widget.AppCompatTextView
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:text="@{data.reviewTaskName}"
+            android:textColor="@color/color_FF333333"
+            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.type}"
+            android:textColor="@color/color_FF333333"
+            android:textSize="@dimen/divider_24px"
+            android:textStyle="bold" />
+
+        <androidx.appcompat.widget.AppCompatTextView
+            android:id="@+id/tvStatus"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:textColor="@color/color_FF333333"
+            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/view_details"
+            android:textColor="@color/color_FF333333"
+            android:textSize="@dimen/divider_24px"
+            android:textStyle="bold" />
+
+    </LinearLayout>
+</layout>

+ 4 - 0
home/src/main/res/values/strings.xml

@@ -51,4 +51,8 @@
     <string name="reference_value" tools:ignore="ResourceName">参考值</string>
     <string name="result" tools:ignore="ResourceName">结果</string>
     <string name="evaluation_history_info" tools:ignore="ExtraTranslation,ResourceName">测评历史</string>
+    <string name="view_details" tools:ignore="ExtraTranslation,ResourceName">查看详情</string>
+    <string name="task_name" tools:ignore="ResourceName">任务名称</string>
+    <string name="assessment_type" tools:ignore="ResourceName">测评类型</string>
+    <string name="whether_evaluate" tools:ignore="ResourceName">是否测评</string>
 </resources>