Browse Source

接入作业票编号自动生成并匹配界面;

Frankensteinly 1 year ago
parent
commit
ebc998be75

+ 5 - 0
app/src/main/java/com/grkj/iscs/MyApplication.kt

@@ -6,6 +6,7 @@ import androidx.multidex.MultiDex
 import com.grkj.iscs.ble.BleUtil
 import com.grkj.iscs.ble.BleUtil
 import com.grkj.iscs.model.Token
 import com.grkj.iscs.model.Token
 import com.grkj.iscs.util.FileUtil
 import com.grkj.iscs.util.FileUtil
+import com.grkj.iscs.util.NetApi
 import com.grkj.iscs.util.NetHttpManager
 import com.grkj.iscs.util.NetHttpManager
 import com.grkj.iscs.util.log.LogUtil
 import com.grkj.iscs.util.log.LogUtil
 
 
@@ -22,6 +23,10 @@ class MyApplication : Application() {
         BleUtil.instance?.initBle(this)
         BleUtil.instance?.initBle(this)
         NetHttpManager.getInstance().initCtx(this)
         NetHttpManager.getInstance().initCtx(this)
         Token.clear(this)
         Token.clear(this)
+        // TODO 方便调试,待删除
+        NetApi.login {
+
+        }
     }
     }
 
 
     override fun attachBaseContext(base: Context?) {
     override fun attachBaseContext(base: Context?) {

+ 10 - 3
app/src/main/java/com/grkj/iscs/activity/CreateTicketActivity.kt

@@ -18,21 +18,28 @@ class CreateTicketActivity : BaseMvpActivity<ICreateTicketView, CreateTicketPres
 
 
     override fun initView() {
     override fun initView() {
         presenter?.initData()
         presenter?.initData()
+        mBinding?.sAutocode?.setOnCheckedChangeListener { _, isChecked ->
+            if (isChecked) {
+                presenter?.getAutoCode { mBinding?.siTicketNumber?.setText(it) }
+            } else {
+                mBinding?.siTicketNumber?.setText(null)
+            }
+        }
     }
     }
 
 
     override fun showSopList(sopList: MutableList<SopPageVO.Record>) {
     override fun showSopList(sopList: MutableList<SopPageVO.Record>) {
         mBinding?.siSop?.mOptionList = sopList.stream().map { it.sopName }.collect(Collectors.toList())
         mBinding?.siSop?.mOptionList = sopList.stream().map { it.sopName }.collect(Collectors.toList())
         mBinding?.siSop?.setOnSpinnerSelectListener(object : SelectableInput.OnSpinnerSelectListener {
         mBinding?.siSop?.setOnSpinnerSelectListener(object : SelectableInput.OnSpinnerSelectListener {
             override fun onSelect(str: String?, index: Int) {
             override fun onSelect(str: String?, index: Int) {
-                presenter?.getSopById(sopList[index].sopId)
+                presenter?.getSopInfo(sopList[index].sopId) {
+                    mBinding?.siSegregationPoint?.setText(it.toString())
+                }
                 mSelectedSopIdx = index
                 mSelectedSopIdx = index
                 val sop = sopList[index]
                 val sop = sopList[index]
                 mBinding?.siWorkshop?.setText(sop.workshopName)
                 mBinding?.siWorkshop?.setText(sop.workshopName)
                 mBinding?.siLine?.setText(sop.workareaName)
                 mBinding?.siLine?.setText(sop.workareaName)
                 mBinding?.siTicketName?.setText("${sop.sopName}-${sop.workshopName}-${sop.workareaName}")
                 mBinding?.siTicketName?.setText("${sop.sopName}-${sop.workshopName}-${sop.workareaName}")
-//                mBinding?.siTicketNumber?.setText(sop.ticketNumber)
                 mBinding?.siTicketType?.setText(presenter?.getTicketTypeName(sop.sopType))
                 mBinding?.siTicketType?.setText(presenter?.getTicketTypeName(sop.sopType))
-//                mBinding?.siSegregationPoint?.setText(sop.pointList.map { it.name }.toString())
             }
             }
         })
         })
     }
     }

+ 32 - 0
app/src/main/java/com/grkj/iscs/model/vo/SopInfoVO.kt

@@ -0,0 +1,32 @@
+package com.grkj.iscs.model.vo
+
+data class SopInfoVO(
+    val sopId: Long?,
+    val sopCode: String?,
+    val sopName: String?,
+    val sopType: String?,
+    val workshopId: Long?,
+    val workareaId: Long?,
+    val sopContent: String?,
+    val sopStatus: String?,
+    val delFlag: String?,
+    val pointDetailVOList: List<PointDetailVO>?
+) {
+    data class PointDetailVO(
+        val pointId: Long?,
+        val pointCode: String?,
+        val pointName: String?,
+        val pointType: String?,
+        val pointTypeName: String?,
+        val workshopId: Long?,
+        val workshopName: String?,
+        val workareaId: Long?,
+        val workareaName: String?,
+        val powerType: String?,
+        val powerTypeName: String?,
+        val isolationMethod: String?,
+        val pointIcon: String?,
+        val pointPicture: String?,
+        val delFlag: String? = null
+    )
+}

+ 16 - 16
app/src/main/java/com/grkj/iscs/presenter/CreateTicketPresenter.kt

@@ -14,28 +14,28 @@ class CreateTicketPresenter : BasePresenter<ICreateTicketView>() {
     var mTicketTypeList = mutableListOf<TicketTypeVO>()
     var mTicketTypeList = mutableListOf<TicketTypeVO>()
 
 
     fun initData() {
     fun initData() {
-        NetApi.login {
-
+        NetApi.getTicketType {
+            mTicketTypeList = it as MutableList<TicketTypeVO>
         }
         }
-        Executor.delayOnMain(5000) {
-            NetApi.getTicketType {
-                mTicketTypeList = it as MutableList<TicketTypeVO>
-            }
-            NetApi.getAutoCode(UrlConsts.AUTOCODE_TICKET_NUMBER) {
-                println("getAutoCode : $it")
-            }
-            NetApi.getSopPage(0, 10) {
-                Executor.runOnMain {
-                    mSopList = it?.records as MutableList<SopPageVO.Record>
-                    mvpView?.showSopList(mSopList)
-                }
+
+        NetApi.getSopPage(0, 10) {
+            Executor.runOnMain {
+                mSopList = it?.records as MutableList<SopPageVO.Record>
+                mvpView?.showSopList(mSopList)
             }
             }
         }
         }
     }
     }
 
 
-    fun getSopById(sopId: Long) {
-        NetApi.getSopInfo(sopId) {
+    fun getAutoCode(callBack: (String?) -> Unit) {
+        NetApi.getAutoCode(UrlConsts.AUTOCODE_TICKET_NUMBER) {
+            callBack.invoke(it)
+        }
+    }
 
 
+    fun getSopInfo(sopId: Long, callBack: (List<String?>?) -> Unit) {
+        NetApi.getSopInfo(sopId) {
+            println("getSopInfo : $it")
+            callBack.invoke(it?.pointDetailVOList?.map { it.pointName })
         }
         }
     }
     }
 
 

+ 3 - 2
app/src/main/java/com/grkj/iscs/util/NetApi.kt

@@ -4,6 +4,7 @@ import com.grkj.iscs.MyApplication
 import com.grkj.iscs.model.AreaTree
 import com.grkj.iscs.model.AreaTree
 import com.grkj.iscs.model.Token
 import com.grkj.iscs.model.Token
 import com.grkj.iscs.model.UrlConsts
 import com.grkj.iscs.model.UrlConsts
+import com.grkj.iscs.model.vo.SopInfoVO
 import com.grkj.iscs.model.vo.SopPageVO
 import com.grkj.iscs.model.vo.SopPageVO
 import com.grkj.iscs.model.vo.TicketTypeVO
 import com.grkj.iscs.model.vo.TicketTypeVO
 
 
@@ -66,7 +67,7 @@ object NetApi {
             }, isGet = true, isAuth = true)
             }, isGet = true, isAuth = true)
     }
     }
 
 
-    fun getSopInfo(sopId: Long, callBack: (String?) -> Unit) {
+    fun getSopInfo(sopId: Long, callBack: (SopInfoVO?) -> Unit) {
         NetHttpManager.getInstance().doRequestNet(
         NetHttpManager.getInstance().doRequestNet(
             UrlConsts.SOP_INFO,
             UrlConsts.SOP_INFO,
             false,
             false,
@@ -75,7 +76,7 @@ object NetApi {
             ),
             ),
             { res, errMsg, codeInt ->
             { res, errMsg, codeInt ->
                 res?.let {
                 res?.let {
-//                    callBack.invoke(it.toString())
+                    callBack.invoke(getRefBean(it))
                 }
                 }
             }, isGet = true, isAuth = true)
             }, isGet = true, isAuth = true)
     }
     }

+ 11 - 0
app/src/main/res/drawable/shape_thumb.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+        android:shape="oval">
+    <solid android:color="@color/white" />
+    <stroke
+            android:width="@dimen/switch_thumb_stroke"
+            android:color="@color/common_transparent" />
+    <size
+            android:width="@dimen/switch_thumb_size"
+            android:height="@dimen/switch_thumb_size" />
+</shape>

+ 6 - 0
app/src/main/res/drawable/track_off.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+        android:shape="rectangle">
+    <solid android:color="@color/switch_track_off" />
+    <corners android:radius="@dimen/switch_radius" />
+</shape>

+ 6 - 0
app/src/main/res/drawable/track_on.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+        android:shape="rectangle">
+    <solid android:color="@color/switch_track_on" />
+    <corners android:radius="@dimen/switch_radius" />
+</shape>

+ 5 - 0
app/src/main/res/drawable/track_selector.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@drawable/track_on" android:state_checked="true" />
+    <item android:drawable="@drawable/track_off" android:state_checked="false" />
+</selector>

+ 19 - 7
app/src/main/res/layout/activity_create_ticket.xml

@@ -54,15 +54,27 @@
             app:mode="input"
             app:mode="input"
             app:name="@string/presentation_ticket_name" />
             app:name="@string/presentation_ticket_name" />
 
 
-        <com.grkj.iscs.widget.SelectableInput
-            android:id="@+id/si_ticket_number"
+        <RelativeLayout
             android:layout_width="match_parent"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_marginTop="7dp"
-            app:edittext_hint="@string/presentation_hint_number"
-            app:enabled="false"
-            app:mode="input"
-            app:name="@string/presentation_ticket_number" />
+            android:layout_marginTop="7dp">
+
+            <androidx.appcompat.widget.SwitchCompat
+                android:id="@+id/s_autocode"
+                style="@style/CommonSwitch"
+                android:layout_alignParentRight="true"
+                android:layout_centerVertical="true" />
+
+            <com.grkj.iscs.widget.SelectableInput
+                android:id="@+id/si_ticket_number"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:layout_toLeftOf="@id/s_autocode"
+                app:edittext_hint="@string/presentation_hint_number"
+                app:mode="input"
+                app:name="@string/presentation_ticket_number" />
+        </RelativeLayout>
 
 
         <com.grkj.iscs.widget.SelectableInput
         <com.grkj.iscs.widget.SelectableInput
             android:id="@+id/si_ticket_type"
             android:id="@+id/si_ticket_type"

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

@@ -6,4 +6,7 @@
 
 
     <color name="main_color">#644bd8</color>
     <color name="main_color">#644bd8</color>
     <color name="selectable_input_prefix">#bd3124</color>
     <color name="selectable_input_prefix">#bd3124</color>
+    <color name="switch_track_on">#298EFF</color>
+    <color name="common_transparent">#00000000</color>
+    <color name="switch_track_off">#E9E9E9</color>
 </resources>
 </resources>

+ 6 - 0
app/src/main/res/values/dimens.xml

@@ -8,6 +8,12 @@
     <dimen name="title_bar_title_text_size">20sp</dimen>
     <dimen name="title_bar_title_text_size">20sp</dimen>
     <dimen name="title_bar_sub_title_text_size">10sp</dimen>
     <dimen name="title_bar_sub_title_text_size">10sp</dimen>
     <dimen name="title_bar_back_size">17dp</dimen>
     <dimen name="title_bar_back_size">17dp</dimen>
+
+    <dimen name="switch_width">46dp</dimen>
+    <dimen name="switch_height">26dp</dimen>
+    <dimen name="switch_radius">13dp</dimen>
+    <dimen name="switch_thumb_stroke">2dp</dimen>
+    <dimen name="switch_thumb_size">22dp</dimen>
     
     
     <dimen name="home_navi_height">200dp</dimen>
     <dimen name="home_navi_height">200dp</dimen>
     <dimen name="home_navi_width">133dp</dimen>
     <dimen name="home_navi_width">133dp</dimen>

+ 8 - 0
app/src/main/res/values/styles.xml

@@ -15,4 +15,12 @@
         <item name="android:scrollbars">none</item>
         <item name="android:scrollbars">none</item>
         <item name="layoutManager">LinearLayoutManager</item>
         <item name="layoutManager">LinearLayoutManager</item>
     </style>
     </style>
+
+    <style name="CommonSwitch">
+        <item name="android:layout_width">@dimen/switch_width</item>
+        <item name="android:layout_height">@dimen/switch_height</item>
+        <item name="android:background">@null</item>
+        <item name="android:thumb">@drawable/shape_thumb</item>
+        <item name="android:track">@drawable/track_selector</item>
+    </style>
 </resources>
 </resources>