瀏覽代碼

完善手动物资更换页面接口适配

Frankensteinly 8 月之前
父節點
當前提交
d131537385

+ 16 - 0
app/src/main/java/com/grkj/iscs_mc/model/UrlConsts.kt

@@ -259,4 +259,20 @@ object UrlConsts {
      * 获取物资柜手动更换物资类型和异常数量和物资信息
      */
     const val MANUAL_REPLACEMENT_LIST = "/iscs/hardware/material-api/selectExMaterialTypeById"
+
+    /**
+     * 查询物资类型-分页
+     */
+    const val MATERIAL_TYPE_PAGE = "/iscs/type/getIsMaterialsTypePage"
+
+    /**
+     * 查询物资属性项-分页
+     */
+    @Deprecated("已废弃")
+    const val MATERIAL_PROPERTY_PAGE = "/iscs/property/getIsMaterialsPropertyPage"
+
+    /**
+     * 查询物资属性值-分页
+     */
+    const val MATERIAL_PROPERTY_VALUE_PAGE = "/iscs/propvalue/getIsMaterialsPropertyValuePage"
 }

+ 26 - 0
app/src/main/java/com/grkj/iscs_mc/model/vo/material/MaterialPropertyPageRespVO.kt

@@ -0,0 +1,26 @@
+package com.grkj.iscs_mc.model.vo.material
+
+data class MaterialPropertyPageRespVO(
+    val current: Int,
+    val optimizeCountSql: Boolean,
+    val orders: List<Any>,
+    val pages: Int,
+    val records: List<Record>,
+    val searchCount: Boolean,
+    val size: Int,
+    val total: Int
+) {
+    data class Record(
+        val propertyId: Long?,
+
+        val propertyName: String?,
+
+        val delFlag: String?,
+
+        val status: String?,
+
+        val startTime: String?,
+
+        val endTime: String?
+    )
+}

+ 21 - 0
app/src/main/java/com/grkj/iscs_mc/model/vo/material/MaterialPropertyValuePageRespVO.kt

@@ -0,0 +1,21 @@
+package com.grkj.iscs_mc.model.vo.material
+
+data class MaterialPropertyValuePageRespVO(
+    val current: Int,
+    val optimizeCountSql: Boolean,
+    val orders: List<Any>,
+    val pages: Int,
+    val records: MutableList<Record>,
+    val searchCount: Boolean,
+    val size: Int,
+    val total: Int
+) {
+    data class Record(
+        val propertyId: Long?,
+        val propertyName: String?,
+        val recordId: Long?,
+        val valueName: String?,
+        val delFlag: String?,
+        val status: String?
+    )
+}

+ 58 - 0
app/src/main/java/com/grkj/iscs_mc/model/vo/material/MaterialTypePageRespVO.kt

@@ -0,0 +1,58 @@
+package com.grkj.iscs_mc.model.vo.material
+
+data class MaterialTypePageRespVO(
+    val current: Int,
+    val optimizeCountSql: Boolean,
+    val orders: List<Any>,
+    val pages: Int,
+    val records: List<Record>,
+    val searchCount: Boolean,
+    val size: Int,
+    val total: Int
+) {
+    data class Record(
+        val materialsTypeId: Long?,
+
+        val materialsTypeCode: String?,
+
+        val materialsTypeName: String?,
+
+        val parentId: Long?,
+
+        val ancestors: String?,
+
+        val enableFlag: String?,
+
+        val serviceLife: String?,
+
+        val availableLife: String?,
+
+        val serviceTimes: Long?,
+
+        val availableTimes: Long?,
+
+        val materialsTypeIcon: String?,
+
+        val materialsTypePicture: String?,
+
+        val delFlag: String?,
+
+        val status: String?,
+
+        val ruleId: Long?,
+
+        val restitutionRequired: Int?,
+
+        val restorationRequired: Int?,
+
+        val loanDuration: Int?,
+
+        val reminderTime: Int?,
+
+        val timeoutAlarm: Int?,
+
+        val checkStandard: String?,
+
+        val propertyIds: String?
+    )
+}

+ 12 - 1
app/src/main/java/com/grkj/iscs_mc/model/vo/replacement/ManualReplacementListRespVO.kt

@@ -64,6 +64,17 @@ data class ManualReplacementListRespVO(
 
         val propertiesProperty: String?,
 
-        val status: String? // 0:正常 1:损坏 2:过期 3:放错柜子
+        val status: String?, // 0:正常 1:损坏 2:过期 3:放错柜子
+
+        /***************App自用数据***************/
+        /**
+         * 选择的类型
+         */
+        var selectedTypeId: Long?,
+
+        /**
+         * 选择的型号
+         */
+        var selectedModelId: Long?
     )
 }

+ 61 - 0
app/src/main/java/com/grkj/iscs_mc/util/NetApi.kt

@@ -17,6 +17,9 @@ import com.grkj.iscs_mc.model.vo.material.MaterialBorrowReturnReqVO
 import com.grkj.iscs_mc.model.vo.material.MaterialDetailRespVO
 import com.grkj.iscs_mc.model.vo.material.MaterialInstructionListRespVO
 import com.grkj.iscs_mc.model.vo.material.MaterialListRespVO
+import com.grkj.iscs_mc.model.vo.material.MaterialPropertyPageRespVO
+import com.grkj.iscs_mc.model.vo.material.MaterialPropertyValuePageRespVO
+import com.grkj.iscs_mc.model.vo.material.MaterialTypePageRespVO
 import com.grkj.iscs_mc.model.vo.replacement.ManualReplacementListRespVO
 import com.grkj.iscs_mc.model.vo.sop.SopInfoRespVO
 import com.grkj.iscs_mc.model.vo.sop.SopPageRespVO
@@ -922,4 +925,62 @@ object NetApi {
             }, isGet = true, isAuth = true
         )
     }
+
+    /**
+     * 查询物资类型-分页
+     */
+    fun getMaterialTypePage(current: Int, size: Int, callBack: (MaterialTypePageRespVO?) -> Unit) {
+        NetHttpManager.getInstance().doRequestNet(
+            UrlConsts.MATERIAL_TYPE_PAGE,
+            false,
+            mapOf(
+                "current" to current,
+                "size" to size
+            ),
+            { res, _, _ ->
+                res?.let {
+                    callBack.invoke(getRefBean(it))
+                }
+            }, isGet = true, isAuth = true
+        )
+    }
+
+    /**
+     * 查询物资属性项-分页
+     */
+    @Deprecated("已废弃")
+    fun getMaterialPropertyPage(current: Int, size: Int, callBack: (MaterialPropertyPageRespVO?) -> Unit) {
+        NetHttpManager.getInstance().doRequestNet(
+            UrlConsts.MATERIAL_PROPERTY_PAGE,
+            false,
+            mapOf(
+                "current" to current,
+                "size" to size
+            ),
+            { res, _, _ ->
+                res?.let {
+                    callBack.invoke(getRefBean(it))
+                }
+            },isGet = true, isAuth = true
+        )
+    }
+
+    /**
+     * 查询物资属性值-分页
+     */
+    fun getMaterialPropertyValuePage(current: Int, size: Int, callBack: (MaterialPropertyValuePageRespVO?) -> Unit) {
+        NetHttpManager.getInstance().doRequestNet(
+            UrlConsts.MATERIAL_PROPERTY_VALUE_PAGE,
+            false,
+            mapOf(
+                "current" to current,
+                "size" to size
+            ),
+            { res, _, _ ->
+                res?.let {
+                    callBack.invoke(getRefBean(it))
+                }
+            },isGet = true, isAuth = true
+        )
+    }
 }

+ 85 - 7
app/src/main/java/com/grkj/iscs_mc/view/fragment/MaterialManualReplacementFragment.kt

@@ -1,14 +1,17 @@
 package com.grkj.iscs_mc.view.fragment
 
-import android.view.View
+import com.bumptech.glide.Glide
 import com.grkj.iscs_mc.R
 import com.grkj.iscs_mc.databinding.FragmentMaterialManualReplacementBinding
 import com.grkj.iscs_mc.extentions.navigateUp
+import com.grkj.iscs_mc.model.vo.material.MaterialPropertyValuePageRespVO
+import com.grkj.iscs_mc.model.vo.material.MaterialTypePageRespVO
 import com.grkj.iscs_mc.model.vo.replacement.ManualReplacementListRespVO
 import com.grkj.iscs_mc.view.base.BaseMvpFragment
 import com.grkj.iscs_mc.view.iview.IMaterialManualReplacementView
 import com.grkj.iscs_mc.view.presenter.MaterialManualReplacementPresenter
 import com.grkj.iscs_mc.view.widget.ExpandableTabLayout
+import com.grkj.iscs_mc.view.widget.SelectableInput
 import com.zhy.adapter.recyclerview.CommonAdapter
 import com.zhy.adapter.recyclerview.base.ViewHolder
 
@@ -18,8 +21,10 @@ import com.zhy.adapter.recyclerview.base.ViewHolder
 class MaterialManualReplacementFragment :
     BaseMvpFragment<IMaterialManualReplacementView, MaterialManualReplacementPresenter, FragmentMaterialManualReplacementBinding>() {
 
-    private val mTypeList = mutableListOf<ManualReplacementListRespVO>()
+    private val mMaterialList = mutableListOf<ManualReplacementListRespVO>()
     private val mDetailList = mutableListOf<ManualReplacementListRespVO.MaterialsPageVO>()
+    private val mTypeList = mutableListOf<MaterialTypePageRespVO.Record>()
+    private val mPropertyList = mutableListOf<MaterialPropertyValuePageRespVO.Record>()
 
     override val viewBinding: FragmentMaterialManualReplacementBinding
         get() = FragmentMaterialManualReplacementBinding.inflate(layoutInflater)
@@ -38,14 +43,64 @@ class MaterialManualReplacementFragment :
                     vo: ManualReplacementListRespVO.MaterialsPageVO,
                     position: Int
                 ) {
+                    // 旧
+                    holder.getView<SelectableInput>(R.id.ci_name_old).setText(vo.materialsName)
+                    holder.getView<SelectableInput>(R.id.ci_type_old)
+                        .setText(mTypeList.find { it.materialsTypeId == vo.materialsTypeId }?.materialsTypeName)
+                    holder.getView<SelectableInput>(R.id.ci_model_old)
+                        .setText(mPropertyList.find { it.recordId.toString() == vo.propertiesValueId }?.valueName)
+                    holder.getView<SelectableInput>(R.id.ci_rfid_old).setText(vo.materialsRfid)
+                    holder.getView<SelectableInput>(R.id.ci_date_old).setText(vo.expirationDate)
+                    Glide.with(this@MaterialManualReplacementFragment).load(vo.materialsTypePicture)
+                        .into(holder.getView(R.id.iv_old))
 
+                    // 新
+                    holder.getView<SelectableInput>(R.id.ci_name_new).setText(vo.materialsName)
+
+                    // 类型
+                    val ciType = holder.getView<SelectableInput>(R.id.ci_type_new)
+                    ciType.setOptionList(mTypeList.map { it.materialsTypeName!! }.toMutableList())
+                    ciType.setText(mTypeList.find { it.materialsTypeId == vo.selectedTypeId }?.materialsTypeName)
+                    ciType.setOnSpinnerSelectListener(object :
+                        SelectableInput.OnSpinnerSelectListener {
+                        override fun onSelect(str: String?, index: Int) {
+                            if (vo.selectedTypeId != mTypeList[index].materialsTypeId) {
+                                vo.selectedModelId = null
+                            }
+                            vo.selectedTypeId = mTypeList[index].materialsTypeId
+                            mBinding?.rvReplacement?.adapter?.notifyItemChanged(position)
+                        }
+                    })
+
+                    // 型号
+                    val ciModel = holder.getView<SelectableInput>(R.id.ci_model_new)
+                    ciModel.setOptionList(mPropertyList
+                        .filter {
+                            it.propertyId.toString() ==
+                                    mTypeList.find { it.materialsTypeId == vo.selectedTypeId }?.propertyIds
+                        }
+                        .map { it.valueName!! }
+                        .toMutableList())
+                    ciModel.setText(mPropertyList.find { it.recordId == vo.selectedModelId }?.valueName)
+                    ciModel.setOnSpinnerSelectListener(object :
+                        SelectableInput.OnSpinnerSelectListener {
+                        override fun onSelect(str: String?, index: Int) {
+                            vo.selectedModelId = mPropertyList[index].recordId
+                        }
+                    })
+
+                    holder.getView<SelectableInput>(R.id.ci_rfid_new).setText(vo.materialsRfid)
+                    holder.getView<SelectableInput>(R.id.ci_date_new).setText(vo.expirationDate)
+                    Glide.with(this@MaterialManualReplacementFragment)
+                        .load(mTypeList.find { it.materialsTypeId == vo.selectedTypeId }?.materialsTypePicture)
+                        .into(holder.getView(R.id.iv_new))
                 }
             }
 
         mBinding?.etlType?.setOnSelectListener(object : ExpandableTabLayout.OnSelectListener {
             override fun onSelect(position: Int) {
                 mDetailList.clear()
-                mTypeList[position].materials?.let {
+                mMaterialList[position].materials?.let {
                     mDetailList.addAll(it)
                 }
                 mBinding?.rvReplacement?.adapter?.notifyDataSetChanged()
@@ -54,22 +109,45 @@ class MaterialManualReplacementFragment :
 
         presenter?.getManualReplacementList {
             it?.let {
-                mTypeList.addAll(it)
+                mMaterialList.addAll(it)
             }
             val list = mutableListOf<ExpandableTabLayout.ItemData>()
             it?.forEach { itData ->
-                list.add(ExpandableTabLayout.ItemData("${itData.materialsTypeName}(${itData.exNumber})", iconUrl = itData.materialsTypeIcon))
+                list.add(
+                    ExpandableTabLayout.ItemData(
+                        "${itData.materialsTypeName}(${itData.exNumber})",
+                        iconUrl = itData.materialsTypeIcon
+                    )
+                )
             }
             mBinding?.etlType?.setData(list)
 
             mDetailList.clear()
-            if (mTypeList.isNotEmpty()) {
-                mTypeList[0].materials?.let {
+            if (mMaterialList.isNotEmpty()) {
+                mMaterialList[0].materials?.let {
                     mDetailList.addAll(it)
                 }
+                mDetailList.forEach {
+                    it.selectedTypeId = it.materialsTypeId
+                    it.selectedModelId = it.propertiesValueId?.toLong()
+                }
             }
             mBinding?.rvReplacement?.adapter?.notifyDataSetChanged()
         }
+
+        presenter?.getMaterialType {
+            if (!it?.records.isNullOrEmpty()) {
+                mTypeList.addAll(it?.records!!)
+                mBinding?.rvReplacement?.adapter?.notifyDataSetChanged()
+            }
+        }
+
+        presenter?.getMaterialProperty {
+            if (!it.isNullOrEmpty()) {
+                mPropertyList.addAll(it)
+                mBinding?.rvReplacement?.adapter?.notifyDataSetChanged()
+            }
+        }
     }
 
     override fun initPresenter(): MaterialManualReplacementPresenter {

+ 18 - 0
app/src/main/java/com/grkj/iscs_mc/view/presenter/MaterialManualReplacementPresenter.kt

@@ -1,6 +1,8 @@
 package com.grkj.iscs_mc.view.presenter
 
 import com.grkj.iscs_mc.extentions.serialNo
+import com.grkj.iscs_mc.model.vo.material.MaterialPropertyValuePageRespVO
+import com.grkj.iscs_mc.model.vo.material.MaterialTypePageRespVO
 import com.grkj.iscs_mc.model.vo.replacement.ManualReplacementListRespVO
 import com.grkj.iscs_mc.util.Executor
 import com.grkj.iscs_mc.util.NetApi
@@ -16,4 +18,20 @@ class MaterialManualReplacementPresenter : BasePresenter<IMaterialManualReplacem
             }
         }
     }
+
+    fun getMaterialType(callBack: (MaterialTypePageRespVO?) -> Unit) {
+        NetApi.getMaterialTypePage(1, -1) {
+            Executor.runOnMain {
+                callBack(it)
+            }
+        }
+    }
+
+    fun getMaterialProperty(callBack: (MutableList<MaterialPropertyValuePageRespVO.Record>?) -> Unit) {
+        NetApi.getMaterialPropertyValuePage(1, -1) {
+            Executor.runOnMain {
+                callBack(it?.records)
+            }
+        }
+    }
 }

+ 6 - 1
app/src/main/java/com/grkj/iscs_mc/view/widget/SelectableInput.kt

@@ -30,7 +30,7 @@ class SelectableInput(private val ctx: Context, attrs: AttributeSet) : LinearLay
     private var mBinding: LayoutSelectableInputBinding
     private var mDropdownView: View? = null
     private var mPopWindow: PopupWindow? = null
-    var mOptionList = mutableListOf<String>()
+    private val mOptionList = mutableListOf<String>()
     private var isSkipListener: Boolean = true
     private var mSelectListener: OnSpinnerSelectListener? = null
     var mSelectIdx: Int? = null
@@ -137,6 +137,11 @@ class SelectableInput(private val ctx: Context, attrs: AttributeSet) : LinearLay
         return mBinding.et.text.toString()
     }
 
+    fun setOptionList(list: MutableList<String>) {
+        mOptionList.clear()
+        mOptionList.addAll(list)
+    }
+
     private fun showDropdown() {
         mDropdownView?:let {
             mDropdownView = LayoutInflater.from(ctx).inflate(R.layout.layout_selectableinput_spinner, null)

+ 2 - 0
app/src/main/res/layout/item_rv_manual_replacement.xml

@@ -85,6 +85,7 @@
                 android:layout_height="68dp">
 
                 <ImageView
+                    android:id="@+id/iv_old"
                     android:layout_width="53dp"
                     android:layout_height="53dp"
                     android:layout_centerInParent="true" />
@@ -197,6 +198,7 @@
                 android:layout_height="68dp">
 
                 <ImageView
+                    android:id="@+id/iv_new"
                     android:layout_width="53dp"
                     android:layout_height="53dp"
                     android:layout_centerInParent="true" />