Procházet zdrojové kódy

优化异常上报弹出键盘时显示效果;完成异常上报功能

Frankensteinly před 7 měsíci
rodič
revize
570ce183f1

+ 2 - 1
app/src/main/AndroidManifest.xml

@@ -42,7 +42,8 @@
             android:exported="false" />
         <activity
             android:name=".view.activity.HomeActivity"
-            android:exported="false" />
+            android:exported="false"
+            android:windowSoftInputMode="adjustPan|adjustResize" />
         <activity
             android:name=".view.activity.LoginActivity"
             android:exported="false"

+ 22 - 1
app/src/main/java/com/grkj/iscs/model/UrlConsts.kt

@@ -22,10 +22,15 @@ object UrlConsts {
      */
     const val SOP_PAGE = "/iscs/mars/sop/getIsMarsSopPage"
 
+    /**
+     * 字典前缀
+     */
+    private const val DICT_PREFIX = "/system/dict/data/type"
+
     /**
      * 查询字典 - 工作票类型
      */
-    const val TICKET_TYPE = "/system/dict/data/type/ticket_type"
+    const val TICKET_TYPE = "$DICT_PREFIX/ticket_type"
 
     /**
      * 获取一个自动生成的编码
@@ -226,4 +231,20 @@ object UrlConsts {
      * 删除用户特征(指纹、面部)
      */
     const val REMOVE_USER_CHARACTERISTIC = "/system/user/characteristic/removeSysUserCharacteristicByRecordIds"
+
+    /**
+     * 新增异常记录
+     */
+    const val INSERT_EXCEPTION = "/iscs/exception/insertIsException"
+
+    /**
+     * 查询字典 - 人工异常类型
+     */
+    const val EXCEPTION_TYPE = "$DICT_PREFIX/exception_type"
+
+    /**
+     * 查询字典 - 人工异常严重等级
+     */
+    const val EXCEPTION_LEVEL = "$DICT_PREFIX/severity_level"
+
 }

+ 18 - 0
app/src/main/java/com/grkj/iscs/model/vo/dict/CommonDictRespVO.kt

@@ -0,0 +1,18 @@
+package com.grkj.iscs.model.vo.dict
+
+import com.grkj.iscs.model.vo.ticket.TicketTypeRespVO.Params
+
+data class CommonDictRespVO(
+    val createBy: String?,
+    val createTime: String?,
+    val default: Boolean?,
+    val dictCode: String?,
+    val dictLabel: String?,
+    val dictSort: String?,
+    val dictType: String?,
+    val dictValue: String?,
+    val isDefault: String?,
+    val listClass: String?,
+    val params: Params?,
+    val status: String?
+)

+ 2 - 2
app/src/main/java/com/grkj/iscs/presentation/PresentationActivity.kt

@@ -46,8 +46,8 @@ class PresentationActivity :
             }
         })
 
-        mBinding?.siPersonLock?.setOptionList(PresentationManager.mLockerList.map { it.name } as MutableList)
-        mBinding?.siPersonSafety?.setOptionList(PresentationManager.mSafetyList)
+        mBinding?.siPersonLock?.setOptionList(PresentationManager.mLockerList.map { it.name }.toMutableList())
+        mBinding?.siPersonSafety?.setOptionList(PresentationManager.mSafetyList.toMutableList())
 
         mBinding?.confirm?.setOnClickListener {
             confirm()

+ 60 - 0
app/src/main/java/com/grkj/iscs/util/NetApi.kt

@@ -8,6 +8,7 @@ import com.grkj.iscs.model.vo.FileStreamReqParam
 import com.grkj.iscs.model.vo.card.CardInfoRespVO
 import com.grkj.iscs.model.vo.characteristic.CharacteristicPageRespVO
 import com.grkj.iscs.model.vo.dept.DeptListRespVO
+import com.grkj.iscs.model.vo.dict.CommonDictRespVO
 import com.grkj.iscs.model.vo.finger.LoginFingerprintRespVO
 import com.grkj.iscs.model.vo.key.KeyInfoRespVO
 import com.grkj.iscs.model.vo.lock.LockInfoRespVO
@@ -32,6 +33,10 @@ import com.grkj.iscs.model.vo.user.RoleListRespVO
 import com.grkj.iscs.model.vo.user.UserInfoRespVO
 import com.grkj.iscs.model.vo.user.UserListRespVO
 import com.grkj.iscs.util.log.LogUtil
+import java.text.SimpleDateFormat
+import java.time.LocalDateTime
+import java.util.Calendar
+import java.util.Locale
 
 /**
  * 网络请求
@@ -897,4 +902,59 @@ object NetApi {
             }, isGet = true, isAuth = true
         )
     }
+
+    /**
+     * 新增异常记录
+     *
+     * @param exceptionCategory 异常种类(0-锁控柜 1-物资柜)
+     */
+    fun insertException(
+        exceptionCategory: String,
+        exceptionDescription: String?,
+        exceptionLevel: String,
+        exceptionType: String,
+        raiser: Long,
+        sourceName: String,
+        callBack: (Boolean) -> Unit
+    ) {
+        val map = mutableMapOf(
+            "exceptionCategory" to exceptionCategory,
+            "exceptionLevel" to exceptionLevel,
+            "exceptionType" to exceptionType,
+            "raiser" to raiser,
+            "sourceName" to sourceName,
+            "raiseTime" to SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(Calendar.getInstance().time)
+        )
+        exceptionDescription?.let {
+            map["exceptionDescription"] = it
+        }
+        NetHttpManager.getInstance().doRequestNet(
+            UrlConsts.INSERT_EXCEPTION,
+            false,
+            map,
+            { res, _, _ ->
+                res?.let {
+                    callBack.invoke(true)
+                } ?: run {
+                    callBack.invoke(false)
+                }
+            }, isGet = false, isAuth = true
+        )
+    }
+
+    /**
+     * 查询字典
+     */
+    fun getDictData(url: String, callBack: (MutableList<CommonDictRespVO>?) -> Unit) {
+        NetHttpManager.getInstance().doRequestNet(
+            url,
+            false,
+            mapOf<String, String>(),
+            { res, _, _ ->
+                res?.let {
+                    callBack.invoke(getRefBean(it))
+                }
+            }, isGet = true, isAuth = true
+        )
+    }
 }

+ 1 - 1
app/src/main/java/com/grkj/iscs/view/activity/CreateTicketActivity.kt

@@ -102,7 +102,7 @@ class CreateTicketActivity : BaseMvpActivity<ICreateTicketView, CreateTicketPres
 
     override fun updateLockerList(lockerList: List<String>?) {
         lockerList?.let {
-            mBinding?.siPersonLock?.setOptionList(it as MutableList<String>)
+            mBinding?.siPersonLock?.setOptionList(it.toMutableList())
         }
     }
 

+ 55 - 1
app/src/main/java/com/grkj/iscs/view/fragment/ExceptionReportFragment.kt

@@ -1,20 +1,74 @@
 package com.grkj.iscs.view.fragment
 
+import com.grkj.iscs.R
 import com.grkj.iscs.databinding.FragmentExceptionReportBinding
+import com.grkj.iscs.model.vo.dict.CommonDictRespVO
+import com.grkj.iscs.util.ToastUtils
 import com.grkj.iscs.view.base.BaseMvpFragment
 import com.grkj.iscs.view.iview.IExceptionReportView
 import com.grkj.iscs.view.presenter.ExceptionReportPresenter
+import com.grkj.iscs.view.widget.SelectableInput
 
 /**
  * 异常上报页
  */
-class ExceptionReportFragment : BaseMvpFragment<IExceptionReportView, ExceptionReportPresenter, FragmentExceptionReportBinding>() {
+class ExceptionReportFragment :
+    BaseMvpFragment<IExceptionReportView, ExceptionReportPresenter, FragmentExceptionReportBinding>() {
+
+    private val mExceptionList = mutableListOf<CommonDictRespVO>()
+    private val mLevelList = mutableListOf<CommonDictRespVO>()
+    private var mTypeIdx = -1   // 选中的类型
+    private var mLevelIdx = -1  // 选中的等级
 
     override val viewBinding: FragmentExceptionReportBinding
         get() = FragmentExceptionReportBinding.inflate(layoutInflater)
 
     override fun initView() {
+        presenter?.getExceptionType({
+            it?.let {
+                mTypeIdx = -1
+                mExceptionList.clear()
+                mExceptionList.addAll(it)
+                mBinding?.siType?.setOptionList(mExceptionList.map { it.dictLabel }.toMutableList())
+            }
+        }) {
+            it?.let {
+                mLevelIdx = -1
+                mLevelList.clear()
+                mLevelList.addAll(it)
+                mBinding?.siLevel?.setOptionList(mLevelList.map { it.dictLabel }.toMutableList())
+            }
+        }
+
+        mBinding?.siType?.setOnSpinnerSelectListener(object : SelectableInput.OnSpinnerSelectListener {
+            override fun onSelect(str: String?, index: Int) {
+                mTypeIdx = index
+            }
+        })
+
+        mBinding?.siLevel?.setOnSpinnerSelectListener(object : SelectableInput.OnSpinnerSelectListener {
+            override fun onSelect(str: String?, index: Int) {
+                mLevelIdx = index
+            }
+        })
 
+        mBinding?.cbSubmit?.setOnClickListener {
+            if (mTypeIdx == -1) {
+                ToastUtils.tip(R.string.exception_type_tip)
+                return@setOnClickListener
+            }
+            if (mLevelIdx == -1) {
+                ToastUtils.tip(R.string.exception_level_tip)
+                return@setOnClickListener
+            }
+            presenter?.insertException(
+                mBinding?.siDescription?.getText(),
+                mLevelList[mLevelIdx].dictValue!!,
+                mExceptionList[mTypeIdx].dictValue!!
+            ) {
+                ToastUtils.tip(R.string.exception_submit_success_tip)
+            }
+        }
     }
 
     override fun initPresenter(): ExceptionReportPresenter {

+ 44 - 0
app/src/main/java/com/grkj/iscs/view/presenter/ExceptionReportPresenter.kt

@@ -1,7 +1,51 @@
 package com.grkj.iscs.view.presenter
 
+import com.grkj.iscs.extentions.serialNo
+import com.grkj.iscs.model.Constants.DEVICE_TYPE
+import com.grkj.iscs.model.UrlConsts
+import com.grkj.iscs.model.vo.dict.CommonDictRespVO
+import com.grkj.iscs.util.Executor
+import com.grkj.iscs.util.NetApi
+import com.grkj.iscs.util.SPUtils
 import com.grkj.iscs.view.base.BasePresenter
 import com.grkj.iscs.view.iview.IExceptionReportView
 
 class ExceptionReportPresenter : BasePresenter<IExceptionReportView>() {
+
+    fun getExceptionType(
+        typeCallBack: (MutableList<CommonDictRespVO>?) -> Unit,
+        levelCallBack: (MutableList<CommonDictRespVO>?) -> Unit
+    ) {
+        NetApi.getDictData(UrlConsts.EXCEPTION_TYPE) {
+            Executor.runOnMain {
+                typeCallBack(it)
+            }
+        }
+
+        NetApi.getDictData(UrlConsts.EXCEPTION_LEVEL) {
+            Executor.runOnMain {
+                levelCallBack(it)
+            }
+        }
+    }
+
+    fun insertException(
+        exceptionDescription: String?,
+        exceptionLevel: String,
+        exceptionType: String,
+        callBack: (Boolean) -> Unit
+    ) {
+        NetApi.insertException(
+            if (DEVICE_TYPE == 1) "0" else "1",
+            exceptionDescription,
+            exceptionLevel,
+            exceptionType,
+            SPUtils.getLoginUser(mContext!!)?.userId!!,
+            mContext!!.serialNo()
+        ) {
+            Executor.runOnMain {
+                callBack(it)
+            }
+        }
+    }
 }

+ 4 - 4
app/src/main/java/com/grkj/iscs/view/widget/SelectableInput.kt

@@ -33,7 +33,7 @@ class SelectableInput(private val ctx: Context, attrs: AttributeSet) : LinearLay
     private var mBinding: LayoutSelectableInputBinding
     private var mDropdownView: View? = null
     private var mPopWindow: PopupWindow? = null
-    private val mOptionList = mutableListOf<String>()
+    private val mOptionList = mutableListOf<String?>()
     private var isSkipListener: Boolean = true
     private var mSelectListener: OnSpinnerSelectListener? = null
     private var mTextChangeListener: OnTextChangeListener? = null
@@ -199,7 +199,7 @@ class SelectableInput(private val ctx: Context, attrs: AttributeSet) : LinearLay
         return mBinding.et.text.toString()
     }
 
-    fun setOptionList(list: MutableList<String>) {
+    fun setOptionList(list: MutableList<String?>) {
         mOptionList.clear()
         mOptionList.addAll(list)
     }
@@ -220,9 +220,9 @@ class SelectableInput(private val ctx: Context, attrs: AttributeSet) : LinearLay
             val popBinding = LayoutSelectableinputSpinnerBinding.bind(mDropdownView!!)
             popBinding.rvOptions.adapter = object : CommonAdapter<String>(ctx, R.layout.item_rv_selectableinput_spinner, mOptionList) {
                 override fun convert(holder: ViewHolder?, option: String?, position: Int) {
-                    holder?.setText(R.id.tv_option, option)
+                    holder?.setText(R.id.tv_option, option ?: "")
                     holder?.setOnClickListener(R.id.tv_option) {
-                        mBinding.et.setText(option)
+                        mBinding.et.setText(option ?: "")
                         mSelectListener?.onSelect(option, position)
                         mPopWindow?.dismiss()
                         mSelectIdx = position

+ 5 - 5
app/src/main/res/layout/fragment_exception_report.xml

@@ -7,7 +7,7 @@
     tools:context=".view.fragment.ExceptionReportFragment">
 
     <com.grkj.iscs.view.widget.CommonBtn
-        android:id="@+id/cb_open"
+        android:id="@+id/cb_submit"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentBottom="true"
@@ -19,14 +19,14 @@
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:layout_above="@id/cb_open"
+        android:layout_above="@id/cb_submit"
         android:layout_marginVertical="@dimen/common_spacing"
         android:background="@drawable/item_rv_technology_sop_bg_normal"
         android:orientation="vertical"
         android:padding="@dimen/common_spacing">
 
         <com.grkj.iscs.view.widget.SelectableInput
-            android:id="@+id/ci_type"
+            android:id="@+id/si_type"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginVertical="@dimen/common_spacing"
@@ -38,7 +38,7 @@
             app:text_size="@dimen/common_text_size" />
 
         <com.grkj.iscs.view.widget.SelectableInput
-            android:id="@+id/ci_level"
+            android:id="@+id/si_level"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginVertical="@dimen/common_spacing"
@@ -50,7 +50,7 @@
             app:text_size="@dimen/common_text_size" />
 
         <com.grkj.iscs.view.widget.SelectableInput
-            android:id="@+id/ci_description"
+            android:id="@+id/si_description"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginVertical="@dimen/common_spacing"

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

@@ -223,4 +223,7 @@
     <string name="fingerprint_delete_confirm_tip">确定要删除%s吗?</string>
     <string name="fingerprint_scan_tip">请按压指纹识别区</string>
     <string name="fingerprint_add_success_tip">已成功添加指纹数据</string>
+    <string name="exception_type_tip">请选择异常类型</string>
+    <string name="exception_level_tip">请选择异常等级</string>
+    <string name="exception_submit_success_tip">异常提交成功</string>
 </resources>