Forráskód Böngészése

完成工作票创建流程,补充工作票创建流程中页面切换逻辑

Frankensteinly 9 hónapja
szülő
commit
371f98f1a8

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

@@ -1,8 +1,8 @@
 package com.grkj.iscs.model
 
 object UrlConsts {
-//    const val BASE_URL = "http://192.168.28.82:9190"
-    const val BASE_URL = "http://192.168.28.97:9190"
+    const val BASE_URL = "http://192.168.28.82:9190"
+//    const val BASE_URL = "http://192.168.28.97:9190"
     const val WEB_SOCKET = "ws://192.168.1.127:9090/websocket/iot/127"
 
     const val AUTOCODE_TICKET_NUMBER = "JOB_TICKET_CODE"
@@ -20,7 +20,7 @@ object UrlConsts {
     /**
      * 查询SOP信息-分页
      */
-    const val SOP_PAGE = "/iscs/sop/getIsSopPage"
+    const val SOP_PAGE = "/iscs/mars/sop/getIsMarsSopPage"
 
     /**
      * 查询字典 - 工作票类型

+ 6 - 1
app/src/main/java/com/grkj/iscs/model/vo/sop/SopPageRespVO.kt

@@ -26,7 +26,12 @@ data class SopPageRespVO(
         val workareaId: Long,
         val workareaName: String,
         val workshopId: Long,
-        val workshopName: String
+        val workshopName: String,
+        val sopIndex: Int,
+        val workstationId: Long,
+        val workstationName: String,
+        val machineryId: Long,
+        val machineryName: String
     )
 }
 

+ 12 - 6
app/src/main/java/com/grkj/iscs/util/NetApi.kt

@@ -86,13 +86,15 @@ object NetApi {
     /**
      * 获取SOP分页
      */
-    fun getSopPage(current: Int, size: Int, callBack: (SopPageRespVO?) -> Unit) {
+    fun getSopPage(pages: Int, size: Int, machineryId: Long, sopType: Int, callBack: (SopPageRespVO?) -> Unit) {
         NetHttpManager.getInstance().doRequestNet(
             UrlConsts.SOP_PAGE,
             false,
             mapOf(
-                "current" to current,
-                "size" to size
+                "pages" to pages,
+                "size" to size,
+                "machineryId" to machineryId,
+                "sopType" to sopType
             ),
             { res, _, _ ->
                 res?.let {
@@ -188,15 +190,19 @@ object NetApi {
 
     /**
      * 创建工作票
+     *
+     * @return 工作票ID
      */
-    fun createTicket() {
+    fun createTicket(sopId: Long, callBack: (Long?) -> Unit) {
         NetHttpManager.getInstance().doRequestNet(
             UrlConsts.CREATE_TICKET,
             false,
-            mapOf<String, String>(),
+            mapOf(
+                "sopId" to sopId
+            ),
             { res, _, _ ->
                 res?.let {
-                    //TODO 创建工作票结果
+                    callBack.invoke(getRefBean(it))
                 }
             }, isGet = false, isAuth = true
         )

+ 5 - 3
app/src/main/java/com/grkj/iscs/view/fragment/JobExecutionFragment.kt

@@ -14,16 +14,17 @@ class JobExecutionFragment :
     BaseMvpFragment<IJobExecutionView, JobExecutionPresenter, FragmentJobExecutionBinding>() {
 
     private lateinit var mMenuList: MutableList<Menu>
+    private var mTicketId: Long? = null
 
     override val viewBinding: FragmentJobExecutionBinding
         get() = FragmentJobExecutionBinding.inflate(layoutInflater)
 
     override fun initView() {
         mMenuList = mutableListOf(
-            Menu(fragment = StepFragment({ refreshPage() }) {
+            Menu(fragment = StepFragment({ refreshPage(mTicketId!!) }) {
                 changePage(it)
             }),
-            Menu(fragment = WorkerFragment({ refreshPage() }) {
+            Menu(fragment = WorkerFragment({ refreshPage(mTicketId!!) }) {
                 changePage(it)
             }),
             Menu(fragment = JobProgressFragment())
@@ -37,7 +38,8 @@ class JobExecutionFragment :
         return JobExecutionPresenter()
     }
 
-    fun refreshPage() {
+    fun refreshPage(ticketId: Long) {
+        mTicketId = ticketId
         mBinding?.vp?.currentItem = 0
     }
 

+ 9 - 6
app/src/main/java/com/grkj/iscs/view/fragment/JobManagementFragment.kt

@@ -24,10 +24,12 @@ class JobManagementFragment :
 
     override fun initView() {
         mMenuList = mutableListOf(
-            Menu(getString(R.string.workshop), R.mipmap.workshop, WorkshopFragment { pageIdx, workstationId, ticketId ->
-                changePage(pageIdx, if (pageIdx == 1) workstationId else ticketId)
+            Menu(getString(R.string.workshop), R.mipmap.workshop, WorkshopFragment { pageIdx, workstationId, ticketId, machineryName ->
+                changePage(pageIdx, machineryName, if (pageIdx == 1) workstationId else ticketId)
+            }),
+            Menu(getString(R.string.technology_sop), R.mipmap.technology, TechnologySopFragment { pageIdx, ticketId ->
+                changePage(pageIdx, data = ticketId)
             }),
-            Menu(getString(R.string.technology_sop), R.mipmap.technology, TechnologySopFragment()),
             Menu(getString(R.string.job_execution), R.mipmap.job_execution, JobExecutionFragment())
         )
 
@@ -42,6 +44,7 @@ class JobManagementFragment :
                 holder.setOnClickListener(R.id.root) {
                     if (position == 0) {
                         mBinding?.vp?.currentItem = 0
+                        (mMenuList[0].fragment as WorkshopFragment).refreshPage()
                         notifyDataSetChanged()
                     }
                 }
@@ -50,10 +53,10 @@ class JobManagementFragment :
         }
     }
 
-    private fun changePage(pageIndex: Int, data: Any? = null) {
+    private fun changePage(pageIndex: Int, title: String? = null, data: Any? = null) {
         when (pageIndex) {
-            1 -> (mMenuList[1].fragment as TechnologySopFragment).refreshPage("", data as Long)
-            2 -> (mMenuList[2].fragment as JobExecutionFragment).refreshPage()
+            1 -> (mMenuList[1].fragment as TechnologySopFragment).refreshPage(title, data as Long)
+            2 -> (mMenuList[2].fragment as JobExecutionFragment).refreshPage(data as Long)
         }
         mBinding?.vp?.currentItem = pageIndex
         mBinding?.rvTab?.adapter?.notifyDataSetChanged()

+ 9 - 7
app/src/main/java/com/grkj/iscs/view/fragment/TechnologySopFragment.kt

@@ -8,7 +8,6 @@ import com.grkj.iscs.R
 import com.grkj.iscs.databinding.FragmentTechnologySopBinding
 import com.grkj.iscs.model.Constants.mSopTypeList
 import com.grkj.iscs.model.vo.machinery.MachineryPageRespVO
-import com.grkj.iscs.presentation.PresentationManager.mSopList
 import com.grkj.iscs.view.base.BaseMvpFragment
 import com.grkj.iscs.view.iview.ITechnologySopView
 import com.grkj.iscs.view.presenter.TechnologySopPresenter
@@ -17,8 +16,10 @@ import com.zhy.adapter.recyclerview.base.ViewHolder
 
 /**
  * 工艺SOP页
+ *
+ * @param changePage 页面index、工作票ID
  */
-class TechnologySopFragment :
+class TechnologySopFragment(val changePage: (Int, Long) -> Unit) :
     BaseMvpFragment<ITechnologySopView, TechnologySopPresenter, FragmentTechnologySopBinding>() {
 
     private val mMachineryList = mutableListOf<MachineryPageRespVO.Record>()
@@ -73,15 +74,16 @@ class TechnologySopFragment :
             }
         }
 
-        // TODO 测试数据
-        refreshPage("本地测试工艺", 8)
-
         mBinding?.cbStart?.setOnClickListener {
-
+            presenter?.createTicket(mMachineryIdx, mSopTypeIdx, mMachineryList) {
+                it?.let {
+                    changePage(2, it)
+                }
+            }
         }
     }
 
-    fun refreshPage(title: String, workstationId: Long) {
+    fun refreshPage(title: String?, workstationId: Long) {
         mBinding?.tvTitle?.text = title
         presenter?.getMachineryPage(workstationId) {
             mMachineryList.clear()

+ 6 - 5
app/src/main/java/com/grkj/iscs/view/fragment/WorkshopFragment.kt

@@ -21,9 +21,9 @@ import java.io.IOException
 /**
  * 车间岗位页
  *
- * @param changePage: page页、workstationId、ticketId
+ * @param changePage: page页、workstationId、ticketId、工艺名
  */
-class WorkshopFragment(val changePage: (Int, Long, Long?) -> Unit) :
+class WorkshopFragment(val changePage: (Int, Long, Long?, String) -> Unit) :
     BaseMvpFragment<IWorkshopView, WorkshopPresenter, FragmentWorkshopBinding>() {
 
     private lateinit var jobStatisticList: MutableList<JobStatistics>
@@ -54,6 +54,7 @@ class WorkshopFragment(val changePage: (Int, Long, Long?) -> Unit) :
             }
         }
 
+        initMap()
         refreshPage()
     }
 
@@ -69,7 +70,7 @@ class WorkshopFragment(val changePage: (Int, Long, Long?) -> Unit) :
                 itPoint.ticketList = it.filter { it.workstationId == itPoint.workstationId }.toMutableList()
             }
             mBinding?.rvStatistics?.adapter?.notifyDataSetChanged()
-            initMap()
+            mBinding?.mapview?.refresh()
         }
     }
 
@@ -90,9 +91,9 @@ class WorkshopFragment(val changePage: (Int, Long, Long?) -> Unit) :
                     override fun markIsClick(index: Int, btnIndex: Int) {
 //                        ToastUtils.tip(mPointList[index].name + " is selected, btnIndex is " + btnIndex)
                         if (btnIndex == -1) {
-                            changePage(1, mPointList[index].workstationId, null)
+                            changePage(1, mPointList[index].workstationId, null, mPointList[index].name)
                         } else {
-                            changePage(2, mPointList[index].workstationId, mPointList[index].ticketList[btnIndex].ticketId)
+                            changePage(2, mPointList[index].workstationId, mPointList[index].ticketList[btnIndex].ticketId, mPointList[index].name)
                         }
                     }
                 })

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

@@ -23,12 +23,12 @@ class CreateTicketPresenter : BasePresenter<ICreateTicketView>() {
             mTicketTypeList = it as MutableList<TicketTypeRespVO>
         }
 
-        NetApi.getSopPage(0, 10) {
-            Executor.runOnMain {
-                mSopList = it?.records as MutableList<SopPageRespVO.Record>
-                mvpView?.showSopList(mSopList)
-            }
-        }
+//        NetApi.getSopPage(0, 10) {
+//            Executor.runOnMain {
+//                mSopList = it?.records as MutableList<SopPageRespVO.Record>
+//                mvpView?.showSopList(mSopList)
+//            }
+//        }
 
         NetApi.getDeptList(0, 10) {
             println("getDeptList : $it")

+ 31 - 1
app/src/main/java/com/grkj/iscs/view/presenter/TechnologySopPresenter.kt

@@ -1,18 +1,48 @@
 package com.grkj.iscs.view.presenter
 
+import com.grkj.iscs.R
 import com.grkj.iscs.model.vo.machinery.MachineryPageRespVO
 import com.grkj.iscs.util.Executor
 import com.grkj.iscs.util.NetApi
+import com.grkj.iscs.util.ToastUtils
 import com.grkj.iscs.view.base.BasePresenter
 import com.grkj.iscs.view.iview.ITechnologySopView
 
 class TechnologySopPresenter : BasePresenter<ITechnologySopView>() {
 
     fun getMachineryPage(workstationId: Long, callBack: (MachineryPageRespVO?) -> Unit) {
-        NetApi.getMachineryPage(0, 10, workstationId) {
+        NetApi.getMachineryPage(0, 100, workstationId) {
             Executor.runOnMain {
                 callBack(it)
             }
         }
     }
+
+    /**
+     * 创建工作票
+     */
+    fun createTicket(
+        machineryIdx: Int,
+        sopTypeIdx: Int,
+        list: MutableList<MachineryPageRespVO.Record>,
+        callBack: (Long?) -> Unit
+    ) {
+        if (machineryIdx == -1) {
+            ToastUtils.tip(R.string.please_select_machinery)
+            return
+        }
+        if (sopTypeIdx == -1) {
+            ToastUtils.tip(R.string.please_select_sop_type)
+            return
+        }
+        NetApi.getSopPage(0, 100, list[machineryIdx].machineryId!!, list[machineryIdx].sysDictDatas?.get(sopTypeIdx)?.dictValue!!.toInt()) {
+            it?.let { itRst ->
+                NetApi.createTicket(itRst.records[0].sopId) { ticketId ->
+                    Executor.runOnMain {
+                        callBack(ticketId)
+                    }
+                }
+            }
+        }
+    }
 }

+ 1 - 1
app/src/main/java/com/grkj/iscs/view/presenter/WorkshopPresenter.kt

@@ -9,7 +9,7 @@ import com.grkj.iscs.view.iview.IWorkshopView
 class WorkshopPresenter : BasePresenter<IWorkshopView>() {
 
     fun getWorkstationTicketList(callBack: (MutableList<WorkstationTicketListRespVO>?) -> Unit) {
-        NetApi.getWorkstationTicketList(0, 10) {
+        NetApi.getWorkstationTicketList(0, 100) {
             Executor.runOnMain {
                 callBack(it)
             }

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

@@ -154,4 +154,6 @@
     <string name="unlocked">已解锁</string>
     <string name="locked">未解锁</string>
     <string name="go_unlocking">去解锁</string>
+    <string name="please_select_machinery">请选择工艺</string>
+    <string name="please_select_sop_type">请选择SOP类型</string>
 </resources>