|
|
@@ -1,13 +1,23 @@
|
|
|
package com.grkj.iscs.view.fragment
|
|
|
|
|
|
+import android.graphics.Bitmap
|
|
|
+import android.graphics.BitmapFactory
|
|
|
import android.widget.ImageView
|
|
|
import com.grkj.iscs.R
|
|
|
import com.grkj.iscs.databinding.FragmentWorkshopBinding
|
|
|
+import com.grkj.iscs.model.Constants.TICKET_TYPE_CHANGE_SHIFTS
|
|
|
+import com.grkj.iscs.model.Constants.TICKET_TYPE_CLEAN
|
|
|
+import com.grkj.iscs.model.Constants.TICKET_TYPE_PRE_MAINTENANCE
|
|
|
+import com.grkj.iscs.model.Constants.TICKET_TYPE_REPAIR
|
|
|
+import com.grkj.iscs.model.Constants.TICKET_TYPE_SWITCH_PRODUCT
|
|
|
+import com.grkj.iscs.util.ToastUtils
|
|
|
import com.grkj.iscs.view.base.BaseMvpFragment
|
|
|
import com.grkj.iscs.view.iview.IWorkshopView
|
|
|
import com.grkj.iscs.view.presenter.WorkshopPresenter
|
|
|
+import com.onlylemi.mapview.library.MapViewListener
|
|
|
import com.zhy.adapter.recyclerview.CommonAdapter
|
|
|
import com.zhy.adapter.recyclerview.base.ViewHolder
|
|
|
+import java.io.IOException
|
|
|
|
|
|
/**
|
|
|
* 车间岗位页
|
|
|
@@ -22,24 +32,76 @@ class WorkshopFragment :
|
|
|
|
|
|
override fun initView() {
|
|
|
jobStatisticList = mutableListOf(
|
|
|
- JobStatistics(R.mipmap.repair, getString(R.string.repair), 0),
|
|
|
- JobStatistics(R.mipmap.pre_maintenance, getString(R.string.pre_maintenance), 0),
|
|
|
- JobStatistics(R.mipmap.change_shifts, getString(R.string.change_shifts), 0),
|
|
|
- JobStatistics(R.mipmap.clean, getString(R.string.clean), 0),
|
|
|
- JobStatistics(R.mipmap.switch_product, getString(R.string.switch_product), 0),
|
|
|
+ JobStatistics(R.mipmap.repair, TICKET_TYPE_REPAIR, getString(R.string.repair), 0),
|
|
|
+ JobStatistics(R.mipmap.pre_maintenance, TICKET_TYPE_PRE_MAINTENANCE, getString(R.string.pre_maintenance), 0),
|
|
|
+ JobStatistics(R.mipmap.change_shifts, TICKET_TYPE_CHANGE_SHIFTS, getString(R.string.change_shifts), 0),
|
|
|
+ JobStatistics(R.mipmap.clean, TICKET_TYPE_CLEAN, getString(R.string.clean), 0),
|
|
|
+ JobStatistics(R.mipmap.switch_product, TICKET_TYPE_SWITCH_PRODUCT, getString(R.string.switch_product), 0),
|
|
|
)
|
|
|
|
|
|
mBinding?.rvStatistics?.adapter = object : CommonAdapter<JobStatistics>(requireActivity(), R.layout.item_rv_job_management, jobStatisticList) {
|
|
|
override fun convert(holder: ViewHolder, statistic: JobStatistics, position: Int) {
|
|
|
holder.getView<ImageView>(R.id.iv).setImageResource(statistic.icon)
|
|
|
- holder.setText(R.id.tv_name, if (statistic.count == 0) statistic.title else "${statistic.title}(${statistic.count})")
|
|
|
+ holder.setText(R.id.tv_name, if (statistic.count == 0) statistic.title else "${statistic.title}(${statistic.count})")
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ initMap()
|
|
|
+
|
|
|
+ refreshPage()
|
|
|
+ }
|
|
|
+
|
|
|
+ fun refreshPage() {
|
|
|
+ presenter?.getWorkstationTicketList {
|
|
|
+ if (it == null) {
|
|
|
+ return@getWorkstationTicketList
|
|
|
+ }
|
|
|
+ jobStatisticList.forEach { itJob ->
|
|
|
+ itJob.count = it.count { it.ticketType == itJob.type.toString() }
|
|
|
+ }
|
|
|
+ mBinding?.rvStatistics?.adapter?.notifyDataSetChanged()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun initMap() {
|
|
|
+ var bitmap: Bitmap? = null
|
|
|
+ try {
|
|
|
+ bitmap = BitmapFactory.decodeStream(requireActivity().assets.open("map.png"))
|
|
|
+ } catch (e: IOException) {
|
|
|
+ e.printStackTrace()
|
|
|
+ }
|
|
|
+
|
|
|
+ mBinding?.mapview?.isScaleAndRotateTogether = false
|
|
|
+ mBinding?.mapview?.loadMap(bitmap)
|
|
|
+ mBinding?.mapview?.setMapViewListener(object : MapViewListener {
|
|
|
+ override fun onMapLoadSuccess() {
|
|
|
+// val marks: List<PointF> = TestData.getMarks()
|
|
|
+// val marksName: List<String> = TestData.getMarksName()
|
|
|
+// val pointList = mutableListOf<CustomPoint>()
|
|
|
+// if (marks.size == marksName.size) {
|
|
|
+// marks.forEachIndexed { index, pointF ->
|
|
|
+// pointList.add(CustomPoint(pointF, marksName[index], index % 3))
|
|
|
+// }
|
|
|
+// }
|
|
|
+// markLayer = CustomMarkLayer(mBinding?.mapview, pointList)
|
|
|
+// markLayer?.setMarkIsClickListener(CustomMarkLayer.MarkIsClickListener { index, btnIndex ->
|
|
|
+// Toast.makeText(
|
|
|
+// applicationContext, marksName[index] + " is selected, btnIndex is " + btnIndex, Toast.LENGTH_SHORT
|
|
|
+// ).show()
|
|
|
+// })
|
|
|
+// mBinding?.mapview?.addLayer(markLayer)
|
|
|
+// mBinding?.mapview?.refresh()
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onMapLoadFail() {
|
|
|
+ ToastUtils.tip("onMapLoadFail")
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
override fun initPresenter(): WorkshopPresenter {
|
|
|
return WorkshopPresenter()
|
|
|
}
|
|
|
|
|
|
- data class JobStatistics(val icon: Int, val title: String, val count: Int)
|
|
|
+ data class JobStatistics(val icon: Int, val type: Int, val title: String, var count: Int)
|
|
|
}
|