|
|
@@ -12,6 +12,7 @@ import com.grkj.iscs.model.bo.PageChangeBO
|
|
|
import com.grkj.iscs.model.vo.machinery.MachineryDetailRespVO
|
|
|
import com.grkj.iscs.model.vo.ticket.LotoMapRespVO
|
|
|
import com.grkj.iscs.model.vo.ticket.StepDetailRespVO
|
|
|
+import com.grkj.iscs.model.vo.ticket.TicketDetailRespVO
|
|
|
import com.grkj.iscs.util.BitmapUtil
|
|
|
import com.grkj.iscs.util.SPUtils
|
|
|
import com.grkj.iscs.util.ToastUtils
|
|
|
@@ -40,6 +41,7 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
private var stationLayer: CustomStationLayer? = null
|
|
|
private val mStationList = mutableListOf<CustomStationLayer.IsolationPoint>()
|
|
|
private var mMapPicWidth = 1
|
|
|
+ private var mTicketDetailData: TicketDetailRespVO? = null
|
|
|
private var mCanHandle: Boolean? = null // 是否可以操作,创建人、上锁人至少符合一个才可操作
|
|
|
|
|
|
override val viewBinding: FragmentStepBinding
|
|
|
@@ -57,44 +59,48 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
StepBO(R.mipmap.step7, getString(R.string.ensure_power_isolation), 6, "⑥"),
|
|
|
StepBO(R.mipmap.step8, getString(R.string.lock_and_hang_a_sign), 5, "⑤")
|
|
|
)
|
|
|
- mBinding?.rvStep?.adapter = object : CommonAdapter<StepBO>(requireContext(), R.layout.item_rv_step, mStepList) {
|
|
|
- override fun convert(holder: ViewHolder, step: StepBO, position: Int) {
|
|
|
- if (step.stepDetail?.stepStatus == "1") {
|
|
|
- holder.getView<MaterialCardView>(R.id.cv_step)
|
|
|
- .setCardBackgroundColor(requireContext().getColor(R.color.item_rv_step_bg_done))
|
|
|
- } else {
|
|
|
- holder.getView<MaterialCardView>(R.id.cv_step).setCardBackgroundColor(
|
|
|
- if (mStep + 1 == step.index)
|
|
|
- requireContext().getColor(R.color.item_rv_step_bg_doing)
|
|
|
- else
|
|
|
- requireContext().getColor(R.color.common_bg_white_10)
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- holder.setVisible(R.id.iv_arrow_right, step.index !in 4..5)
|
|
|
- holder.setVisible(R.id.iv_arrow_bottom, step.index == 4)
|
|
|
- holder.getView<ImageView>(R.id.iv_arrow_right).rotation = if (step.index > 5) 180f else 0f
|
|
|
- holder.getView<ImageView>(R.id.iv_icon).setImageResource(step.pic)
|
|
|
- holder.setText(R.id.tv_name, step.stepDetail?.androidStepContent)
|
|
|
- holder.setText(R.id.tv_index, step.indexStr)
|
|
|
- holder.getView<ImageView>(R.id.iv_status).setImageResource(if (step.stepDetail?.stepStatus == "1") R.mipmap.step_executed else R.mipmap.step_not_executed)
|
|
|
- holder.setText(R.id.tv_status,
|
|
|
+ mBinding?.rvStep?.adapter =
|
|
|
+ object : CommonAdapter<StepBO>(requireContext(), R.layout.item_rv_step, mStepList) {
|
|
|
+ override fun convert(holder: ViewHolder, step: StepBO, position: Int) {
|
|
|
if (step.stepDetail?.stepStatus == "1") {
|
|
|
- if (step.index == 3) getString(R.string.allocated) else getString(R.string.executed)
|
|
|
+ holder.getView<MaterialCardView>(R.id.cv_step)
|
|
|
+ .setCardBackgroundColor(requireContext().getColor(R.color.item_rv_step_bg_done))
|
|
|
} else {
|
|
|
- if (step.index == 3) getString(R.string.not_allocated) else getString(R.string.not_executed)
|
|
|
+ holder.getView<MaterialCardView>(R.id.cv_step).setCardBackgroundColor(
|
|
|
+ if (mStep + 1 == step.index)
|
|
|
+ requireContext().getColor(R.color.item_rv_step_bg_doing)
|
|
|
+ else
|
|
|
+ requireContext().getColor(R.color.common_bg_white_10)
|
|
|
+ )
|
|
|
}
|
|
|
- )
|
|
|
- holder.setOnClickListener(R.id.root) {
|
|
|
- mCanHandle ?: return@setOnClickListener
|
|
|
- if (mCanHandle == false) {
|
|
|
- ToastUtils.tip(R.string.no_permission_to_handle)
|
|
|
- return@setOnClickListener
|
|
|
+
|
|
|
+ holder.setVisible(R.id.iv_arrow_right, step.index !in 4..5)
|
|
|
+ holder.setVisible(R.id.iv_arrow_bottom, step.index == 4)
|
|
|
+ holder.getView<ImageView>(R.id.iv_arrow_right).rotation =
|
|
|
+ if (step.index > 5) 180f else 0f
|
|
|
+ holder.getView<ImageView>(R.id.iv_icon).setImageResource(step.pic)
|
|
|
+ holder.setText(R.id.tv_name, step.stepDetail?.androidStepContent)
|
|
|
+ holder.setText(R.id.tv_index, step.indexStr)
|
|
|
+ holder.getView<ImageView>(R.id.iv_status)
|
|
|
+ .setImageResource(if (step.stepDetail?.stepStatus == "1") R.mipmap.step_executed else R.mipmap.step_not_executed)
|
|
|
+ holder.setText(
|
|
|
+ R.id.tv_status,
|
|
|
+ if (step.stepDetail?.stepStatus == "1") {
|
|
|
+ if (step.index == 3) getString(R.string.allocated) else getString(R.string.executed)
|
|
|
+ } else {
|
|
|
+ if (step.index == 3) getString(R.string.not_allocated) else getString(R.string.not_executed)
|
|
|
+ }
|
|
|
+ )
|
|
|
+ holder.setOnClickListener(R.id.root) {
|
|
|
+ mCanHandle ?: return@setOnClickListener
|
|
|
+ if (mCanHandle == false) {
|
|
|
+ ToastUtils.tip(R.string.no_permission_to_handle)
|
|
|
+ return@setOnClickListener
|
|
|
+ }
|
|
|
+ handleStep(step.index)
|
|
|
}
|
|
|
- handleStep(step.index)
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
mBinding?.cbBack?.setOnClickListener { goBack() }
|
|
|
|
|
|
@@ -132,8 +138,12 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
return@setOnClickListener
|
|
|
}
|
|
|
if (mStep >= 4) {
|
|
|
- changePage(PageChangeBO(2, mChangePage?.workstationId, mChangePage?.ticketId,
|
|
|
- mChangePage?.machineryId, mChangePage?.machineryName))
|
|
|
+ changePage(
|
|
|
+ PageChangeBO(
|
|
|
+ 2, mChangePage?.workstationId, mChangePage?.ticketId,
|
|
|
+ mChangePage?.machineryId, mChangePage?.machineryName
|
|
|
+ )
|
|
|
+ )
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -149,7 +159,8 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
return
|
|
|
}
|
|
|
stationLayer = CustomStationLayer(mBinding?.mapview, mStationList)
|
|
|
- stationLayer?.setMarkIsClickListener(object : CustomStationLayer.MarkIsClickListener {
|
|
|
+ stationLayer?.setMarkIsClickListener(object :
|
|
|
+ CustomStationLayer.MarkIsClickListener {
|
|
|
override fun markIsClick(index: Int, btnIndex: Int) {
|
|
|
// ToastUtils.tip(mPointList[index].name + " is selected, btnIndex is " + btnIndex)
|
|
|
}
|
|
|
@@ -170,6 +181,7 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
mCanHandle = null
|
|
|
|
|
|
presenter?.getTicketDetail(pageChangeBO.ticketId) {
|
|
|
+ mTicketDetailData = it
|
|
|
mBinding?.tvTitle?.text = it?.ticketName
|
|
|
it?.createBy?.let { itCreator ->
|
|
|
if (itCreator.isEmpty()) {
|
|
|
@@ -177,13 +189,17 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
}
|
|
|
mCanHandle = itCreator.toLong() == SPUtils.getLoginUser(requireContext())?.userId
|
|
|
}
|
|
|
- mCanHandle = (mCanHandle == true) || it?.ticketUserVOList?.any { it.userId != null && it.userId.toLong() == SPUtils.getLoginUser(requireContext())?.userId } == true
|
|
|
+ mCanHandle = (mCanHandle == true) || it?.ticketUserVOList?.any {
|
|
|
+ it.userId != null && it.userId.toLong() == SPUtils.getLoginUser(requireContext())?.userId
|
|
|
+ } == true
|
|
|
}
|
|
|
|
|
|
presenter?.getStepDetail(pageChangeBO.ticketId!!) {
|
|
|
BusinessManager.sendLoadingEventMsg(null, false)
|
|
|
- mBinding?.tvWorker?.text = "${it?.get(2)?.userNum}/${it?.get(4)?.userNum}/${it?.get(7)?.userNum}"
|
|
|
- mBinding?.tvLock?.text = "${it?.get(2)?.lockNum}/${it?.get(4)?.lockNum}/${it?.get(7)?.lockNum}"
|
|
|
+ mBinding?.tvWorker?.text =
|
|
|
+ "${it?.get(2)?.userNum}/${it?.get(4)?.userNum}/${it?.get(7)?.userNum}"
|
|
|
+ mBinding?.tvLock?.text =
|
|
|
+ "${it?.get(2)?.lockNum}/${it?.get(4)?.lockNum}/${it?.get(7)?.lockNum}"
|
|
|
mStepList.forEach { step ->
|
|
|
step.stepDetail = it?.find { it.stepIndex == step.index }
|
|
|
}
|
|
|
@@ -203,7 +219,8 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
handleBottomTip()
|
|
|
}
|
|
|
|
|
|
- presenter?.getMachineryDetail(pageChangeBO.machineryId!!,
|
|
|
+ presenter?.getMachineryDetail(
|
|
|
+ pageChangeBO.machineryId!!,
|
|
|
{
|
|
|
mMachineryDetail = it
|
|
|
Glide.with(this).load(it?.machineryImg).into(mBinding?.ivMachinery!!)
|
|
|
@@ -227,16 +244,26 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
val location = IntArray(2)
|
|
|
mBinding?.mapview?.getLocationOnScreen(location)
|
|
|
itMapInfo.pointList?.forEach { itPoint ->
|
|
|
- val locationX = (itPoint.x!!.toFloat() - (itMapInfo.x!!.toFloat() / 50)) * 50 / itMapInfo.width!!.toFloat() * it.width
|
|
|
- val locationY = (itPoint.y!!.toFloat() + 1 - itMapInfo.y!!.toFloat() / 50) * 50 / itMapInfo.height!!.toFloat() * it.height
|
|
|
+ val locationX =
|
|
|
+ (itPoint.x!!.toFloat() - (itMapInfo.x!!.toFloat() / 50)) * 50 / itMapInfo.width!!.toFloat() * it.width
|
|
|
+ val locationY =
|
|
|
+ (itPoint.y!!.toFloat() + 1 - itMapInfo.y!!.toFloat() / 50) * 50 / itMapInfo.height!!.toFloat() * it.height
|
|
|
BitmapUtil.loadBitmapFromUrl(
|
|
|
- requireContext(), itPoint.pointIcon!!, reqWidth = 18, reqHeight = 18
|
|
|
+ requireContext(),
|
|
|
+ itPoint.pointIcon!!,
|
|
|
+ reqWidth = 18,
|
|
|
+ reqHeight = 18
|
|
|
) { itBitmap ->
|
|
|
mStationList.add(
|
|
|
CustomStationLayer.IsolationPoint(
|
|
|
PointF(locationX, locationY),
|
|
|
itPoint.entityName!!,
|
|
|
- itBitmap ?: BitmapUtil.getResizedBitmapFromMipmap(requireContext(), R.mipmap.ticket_type_placeholder, 18, 18),
|
|
|
+ itBitmap ?: BitmapUtil.getResizedBitmapFromMipmap(
|
|
|
+ requireContext(),
|
|
|
+ R.mipmap.ticket_type_placeholder,
|
|
|
+ 18,
|
|
|
+ 18
|
|
|
+ ),
|
|
|
itPoint.entityId!!,
|
|
|
mMachineryDetail?.pointIdList?.contains(itPoint.entityId) == true
|
|
|
)
|
|
|
@@ -257,12 +284,21 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
if (mStep == 0) return
|
|
|
when (step) {
|
|
|
3 -> {
|
|
|
- if (mStep > 5) {
|
|
|
+ if (presenter?.canModifyColocker(requireContext(), step) == true) {
|
|
|
ToastUtils.tip(R.string.current_step_can_not_be_process)
|
|
|
return
|
|
|
}
|
|
|
- changePage(PageChangeBO(1, mChangePage?.workstationId, mChangePage?.ticketId, mChangePage?.machineryId, mChangePage?.machineryName))
|
|
|
+ changePage(
|
|
|
+ PageChangeBO(
|
|
|
+ 1,
|
|
|
+ mChangePage?.workstationId,
|
|
|
+ mChangePage?.ticketId,
|
|
|
+ mChangePage?.machineryId,
|
|
|
+ mChangePage?.machineryName
|
|
|
+ )
|
|
|
+ )
|
|
|
}
|
|
|
+
|
|
|
4 -> {
|
|
|
if (mStep != 3) {
|
|
|
ToastUtils.tip(R.string.current_step_can_not_be_process)
|
|
|
@@ -270,6 +306,7 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
}
|
|
|
updateStep(4)
|
|
|
}
|
|
|
+
|
|
|
5, 6, 7, 8 -> {
|
|
|
if (mStep != step - 1) {
|
|
|
ToastUtils.tip(R.string.current_step_can_not_be_process)
|
|
|
@@ -281,37 +318,66 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
}
|
|
|
|
|
|
private fun updateStep(step: Int) {
|
|
|
- val str = when (step) {
|
|
|
- 4 -> getString(R.string.action_confirm_shut_down)
|
|
|
- 5 -> getString(R.string.action_confirm_lock)
|
|
|
- 6 -> getString(R.string.action_confirm_power_isolation)
|
|
|
- 7 -> getString(R.string.action_confirm_check_before_unlocking)
|
|
|
- 8 -> getString(R.string.action_confirm_restore)
|
|
|
- else -> ""
|
|
|
- }
|
|
|
- mTipDialog.setTip(str)
|
|
|
- mTipDialog.setConfirmListener {
|
|
|
- BusinessManager.sendLoadingEventMsg(getString(R.string.is_processing_please_wait))
|
|
|
- if (step == 4) {
|
|
|
- presenter?.updateStep(mStepList[2].stepDetail?.stepId!!, "1") {
|
|
|
- presenter?.updateStep(mStepList[3].stepDetail?.stepId!!, "1") {
|
|
|
- BusinessManager.sendLoadingEventMsg(null, false)
|
|
|
- refreshPage(mChangePage!!)
|
|
|
- // 自动跳转
|
|
|
- changePage(PageChangeBO(2, mChangePage?.workstationId, mChangePage?.ticketId,
|
|
|
- mChangePage?.machineryId, mChangePage?.machineryName))
|
|
|
+ if (presenter?.checkCanContinue(requireContext(), step, mTicketDetailData)
|
|
|
+ ?.isEmpty() == true
|
|
|
+ ) {
|
|
|
+ val str = when (step) {
|
|
|
+ 4 -> getString(R.string.action_confirm_shut_down)
|
|
|
+ 5 -> getString(R.string.action_confirm_lock)
|
|
|
+ 6 -> getString(R.string.action_confirm_power_isolation)
|
|
|
+ 7 -> getString(R.string.action_confirm_check_before_unlocking)
|
|
|
+ 8 -> getString(R.string.action_confirm_restore)
|
|
|
+ else -> ""
|
|
|
+ }
|
|
|
+ mTipDialog.setTip(str)
|
|
|
+ mTipDialog.setConfirmListener {
|
|
|
+ BusinessManager.sendLoadingEventMsg(getString(R.string.is_processing_please_wait))
|
|
|
+ when (step) {
|
|
|
+ 4 -> {
|
|
|
+ presenter?.updateStep(mStepList[2].stepDetail?.stepId!!, "1") {
|
|
|
+ presenter?.updateStep(mStepList[3].stepDetail?.stepId!!, "1") {
|
|
|
+ BusinessManager.sendLoadingEventMsg(null, false)
|
|
|
+ refreshPage(mChangePage!!)
|
|
|
+ // 自动跳转
|
|
|
+ changePage(
|
|
|
+ PageChangeBO(
|
|
|
+ 2, mChangePage?.workstationId, mChangePage?.ticketId,
|
|
|
+ mChangePage?.machineryId, mChangePage?.machineryName
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- } else {
|
|
|
- presenter?.updateStep(mStepList.find { it.index == step }?.stepDetail?.stepId!!, "1") {
|
|
|
- refreshPage(mChangePage!!)
|
|
|
- if (step == 6 || step == 7) {
|
|
|
- // 自动跳转
|
|
|
- changePage(PageChangeBO(2, mChangePage?.workstationId, mChangePage?.ticketId,
|
|
|
- mChangePage?.machineryId, mChangePage?.machineryName))
|
|
|
+
|
|
|
+ else -> {
|
|
|
+ presenter?.updateStep(
|
|
|
+ mStepList.find { it.index == step }?.stepDetail?.stepId!!,
|
|
|
+ "1"
|
|
|
+ ) {
|
|
|
+ refreshPage(mChangePage!!)
|
|
|
+ if (step == 6 || step == 7) {
|
|
|
+ // 自动跳转
|
|
|
+ changePage(
|
|
|
+ PageChangeBO(
|
|
|
+ 2, mChangePage?.workstationId, mChangePage?.ticketId,
|
|
|
+ mChangePage?.machineryId, mChangePage?.machineryName
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ val str = when (step) {
|
|
|
+ 4 -> getString(R.string.action_confirm_shut_down)
|
|
|
+ 5 -> getString(R.string.action_confirm_lock)
|
|
|
+ 6 -> getString(R.string.action_confirm_power_isolation)
|
|
|
+ 7 -> getString(R.string.action_confirm_check_before_unlocking)
|
|
|
+ 8 -> getString(R.string.action_confirm_restore)
|
|
|
+ else -> ""
|
|
|
+ }
|
|
|
+ mTipDialog.setTip(str)
|
|
|
}
|
|
|
mTipDialog.show()
|
|
|
}
|
|
|
@@ -322,24 +388,32 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
2 -> {
|
|
|
mBinding?.tvTip?.text = getString(R.string.waiting_for_allocating_worker)
|
|
|
}
|
|
|
+
|
|
|
3 -> {
|
|
|
mBinding?.tvTip?.text = getString(R.string.waiting_for_shutting_down)
|
|
|
}
|
|
|
+
|
|
|
4 -> {
|
|
|
mBinding?.tvTip?.text = getString(R.string.waiting_for_hanging_a_sign)
|
|
|
}
|
|
|
+
|
|
|
5 -> {
|
|
|
mBinding?.tvTip?.text = getString(R.string.waiting_for_power_isolation)
|
|
|
}
|
|
|
+
|
|
|
6 -> {
|
|
|
mBinding?.tvTip?.text = getString(R.string.waiting_for_checking_before_unlocking)
|
|
|
}
|
|
|
+
|
|
|
7 -> {
|
|
|
- mBinding?.tvTip?.text = getString(R.string.waiting_for_restoring_switch_before_unlocking)
|
|
|
+ mBinding?.tvTip?.text =
|
|
|
+ getString(R.string.waiting_for_restoring_switch_before_unlocking)
|
|
|
}
|
|
|
+
|
|
|
8 -> {
|
|
|
mBinding?.tvTip?.text = getString(R.string.waiting_for_finishing)
|
|
|
}
|
|
|
+
|
|
|
else -> {
|
|
|
mBinding?.tvTip?.text = ""
|
|
|
}
|
|
|
@@ -355,5 +429,11 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
return StepPresenter()
|
|
|
}
|
|
|
|
|
|
- data class StepBO(val pic: Int, val title: String, val index: Int, val indexStr: String, var stepDetail: StepDetailRespVO? = null)
|
|
|
+ data class StepBO(
|
|
|
+ val pic: Int,
|
|
|
+ val title: String,
|
|
|
+ val index: Int,
|
|
|
+ val indexStr: String,
|
|
|
+ var stepDetail: StepDetailRespVO? = null
|
|
|
+ )
|
|
|
}
|